|
jQueryIncludePlugin
Utility library to include JavaScript and / or CSS on demand.
IntroductionInsert new elementos (tag link and script) in the head of document and loads them. You can pass a file or a array of files mixed. USAGE$.include(String | Array url, Function callback); ExamplesYou can pass a single javascript file$.include('file.js');You can pass a array of files$.include(['file01.js','file02.js']); You can specify the base path to be used in whole call of the plugin$.ImportBasePath = '/foo/test/'; You can even mix the files$.include(['file01.js','file02.css']); The tool support callback too$.include(['file01.js',function(){
//code be executed when script loads
});Still untested - The plugin can check if CSS is loaded too (tricky feature)$.include(['file01.css',function(){
//code be executed when css loads
});SupportThis plugin was tested in IE 6 and Firefox 2+ Jquery version 2.1+ Dependencies
Test pageno test page yet AuthorAlexandre Magno - http://www.alexandremagno.net/blog License |
Sign in to add a comment
Very nice project, i must use this in my projects, But does this support for local caching of Javascript, because normal <script src="foo/test"></script>, as far as I know do some sort of caching in client browser.
Inline javascript does seems NOT to work fine. Here is my js code.
I think its not working in Google Chrome Browser,
This make a lot of requets?
@manalo: you can separate the css files in another call and js files with a callback calling the tabs. I didn´t tested in Google Chrome. I´m having a lot of trouble with it. One more browser to give us headache. @bagulhus: This plugins doesnt make request because they create on the fly script and link tags in head of the document. There´s no ajax request in this plugin.
the current version (1.0) does not support passing along URL get arguments in the script includes. i changed a few lines to accommodate this (starting at line 37 through line 61): `
` line 37 regex was modified to include any characters (not just word ones) then lines 39 and 47 were modified to use indexOf instead of == in the comparison to solve the problem.
thanks for the plugin :)
ie: so now /path/to/javascript.js?withargs=1&moreargs=2 works. before it did not.
I would love to see this script work with elements other than the head. Take a widget codes for example that need to be placed into a container. Where the <script> tag is placed will be where the widget will show up. I checking the source code, this looks like a very feasible task to have the code work like $('#myWidgetDiv').include(... or how it normally is $.include(...
if the latter, it would assume <head> otherwise use the jquery object as the element to appendTo.