I have a framework-less javascript that executes on load:
function myJs() {
// some code
}
window.load = myJs;
But this causes a delay in the execution of the script. I want to be able to execute this script as soon as the document is ready to be manipulated even before the page has completely finished loading. How can this be done in a cross browser compatible way? In other words how can the:
$(document).ready(function() {
//
});
of jQuery be said in plain JS?
Answer
I have made an implementation (based on the one found in jQuery) that you can use: http://github.com/jakobmattsson/onDomReady/blob/master/ondomready.js
No comments:
Post a Comment