I wan开发者_运维技巧t to incorporate a minified javascript library (for example http://sizzlejs.com/) into my own non minified javascript library. The reason is that my library plugs into other websites and I don't want to ask them to include the extra library (sizzle) as well.
Is there a way to include a minified library in a non minified library and have them both in one js file?
The simplest approach would be to just copy and paste the code from the minified library directly into the top of your file.
You could just copy the sizzle code into your own code. That is, at the top or bottom of your js file. This is how jQuery include sizzle in their code.
Or you could dynamically add a script tag element to the "head" of the document in your own library which has src set to the sizzle minified file (look at how jQuery includes scripts in its AJAX routines for an example).
If you include dynamically, you might find that it's actually faster, as you can probably link to sizzle from the google servers, and the user may well have it already cached in their browser (jQuery actually recommend including their own library in this way)
精彩评论