loadjs
loadjs copied to clipboard
Add functionality to wait for document.ready?
trafficstars
What do you think about adding an internal dependency called "document", that's triggered by document.ready?
I faced random issues with jquery dependencies until I realized my jQuery code now got executed before the DOM was ready. Clearly a coding bug on my side, but it got me thinking.
My current workaround is
loadjs(["..."], 'jquery-pre');
loadjs.ready(['jquery-pre'], function() {
$(function() { loadjs.done('jquery'); });
});
Not sure if worth the feature bloat for loadjs
DOM timing with jQuery can definitely get tricky. I'm hesitant to add a jQuery-specific feature but I'll think about it some more. In case it helps you can combine your loadjs calls into one:
loadjs('/path/to/jquery.js', function() {
$(function() {loadjs.done('jquery');});
});
// execute code after jQuery document.ready
loadjs.ready('jquery', function() {
});
Yeah, that's what I'll use, was just waiting for the new release :)