3 ms·
That sounds like a pretty silly drawback. A much cleaner solution would be using window.onload to load all javascript and then only starting execution on docum
by Swizec 16y ago
That sounds like a pretty silly drawback.
A much cleaner solution would be using window.onload to load all javascript and then only starting execution on document.ready.
That way you pretty successfully get around the issue of ordered dependancies because at execution time everything is already loaded. If load.js doesn't do it this way I am profoundly interested as to what the reasoning behind this might be ... perhaps all browser don't differ between window.load and document.ready? (or maybe I'm being stupid in some way or another)
- noibl 16y agodocument.ready fires before window.load
- weixiyen 16y agoWhat you are describing is not lazy-loading. The purpose of lazy loading is to avoid the overhead of having to load all your javascript immediately at the cost of more server requests later on as needed. The benefits of speed gained from lazy-loading can be huge in large applications with little to no browser refresh. The problem with lazy loading javascript in the browser is you have no good way innate to javascript to automatically tell if a script has really been loaded, and the problem you must solve is finding out when you are allowed to execute commands that have dependencies in the lazy loaded scripts.
- Swizec 16y agoThanks for the explanation, was almost certain I was thinking about it wrong :)