views:

94

answers:

1

I'm building a JavaScript library for customers to use to embed content my company's product creates into their own web pages. The content itself is a combination of html and flash with some JavaScript glue. We use swfObject to embed our Flash content.

My question is: What is the best way to manage this dependency?

Currently I'm considering two options:

1) Include a copy of swfObject.js with our distribution and have end users add the script element for swfObject.js themselves.

2) Copy the source of swfObject.js into our own JavaScript library and hide it from our end users.

#1 would be better in that people could have some control over the script that their final pages are using (e.g. they could update swfObject.js to a newer version). Many customer pages I've seen already have some flash content embedded using swfObject, so a single copy of swfObject.js would be efficient.

#2 seems like it would be safer for us since we could test against a known version swfObject.

Are there other, better options? This is my first JavaScript library endeavor, how do people normally do this?

A: 

If you can reasonably expect your end users to be able to add a script element themselves, you may be able to achieve a good compromise between stability and customizability by exposing the Google AJAX Libraries API, which supports swfObject.

google.load("swfobject", "2.2");
Duncan Beevers