jQuery Include
For those of you who like jQuery but cannot find any sensible way of including external JavaScript files, here is a solution for you. I come up with this solution while developing Mashina, my browser based exploitation framework.
http://www.gnucitizen.org/blog/jquery-include/jquery.include.js
In order to include JavaScript source files you have to do the following:
$.include('http://path/to/script1.js');
$.include('http://path/to/script2.js');
$(document).ready(function () {
// the files are loaded, so now you can use them...
});
As you can see, everything is very jQuery like so you shouldn’t have any problems.
Comments
For local files if you use async false then you don’t have to do the callback timer (js stops execution until the file is loaded). This has been working for me in IE6, FF2, & Safari:
I have error (FireBug tested) reported near
how about changing to
This should work fine.
Regards
Arthur Bezner
yes, I will make the changes as soon as possible!
I’ve added link from jQuery wiki to your script. Hope you don’t mind :)
vlad, not really… go crazy… modify it if you want but just let me know about the changes since I make a heavy use of it. cheers
Hi,
I have been trying to implement a set of multi-level includes, but… It seems like the Ready event is firing prematurely. Any suggestions?
Thanks,
Jimmy G
yeh, it is strange… I am not sure what the problem is but I will definitely look into it. thanks for the feedback.
Can you extend your plugin to integrate css stylesheets loading ?
Thanks
LudoO
Hello,
I noticed that if you use
$.include('/foo/bar.js'); combined with jQuery Form Plugin (http://www.malsup.com/jquery/form/) the form plugin doesn’t work :(I couldn’t figure out why exactly.
УÑпех Петко! :>
Иван,
there seams to be a nasty bug with jquery.include. I need to look at it further in my infinite free time. :)
mersi
any progress with this? it’d be very useful. it does look like its in the 1.2 roadmap at least, but no word on timing: http://docs.jquery.com/JQuery_.....ript.28.29
rezn, that would be very useful, at least I don’t have to support this plugin myself :)
It doesnt work because that it dont really hijak ondomready event, which is attached via reference, not name.
I wrote similar plugin with working ondomready and dependency feauture:
http://meta20.net/.include_scr.....ery_plugin
Tested with jquery.forms. Hope you find it usefull.
var test = 10;in a file test.js$include("test.js");in another filealert(test)didn’t work on IE6If you want that run in Internet Explorer, the property readyState is loaded and not complete.
Big problem in printing the polylines in firefox.
It is realy hard to debug when one application use more and more jquery components.
Please insert this line (42) for another programmers: