Speed up page loads, defer your JavaScript
A coworker of mine showed me something today that looks interesting. Say you've got a page with a lot of client site JS code that runs AFTER the page is loaded. Things like form validation, Ajax functions, stuff like that. Well, apparently you can add a defer attribute to your script tag, and the browser will not load the JS file until AFTER the page has been fully loaded and displayed to the user. With JavaScript heavy sites, this could dramatically decrease page load times. Here's an example:
<script src="script.js" type="text/javascript" defer="defer"></script>
I am not sure if this works in all browsers, and I'm not sure if it causes any problems. If anybody has any experience with this, please drop me a comment.
Jake Munson
38 Yrs old
I've always meant to investigate the judicious use of this attribute, but just never made the time for it.
Would love to hear more from you as you monkey with it. Perhaps you'll come across some trick that I've missed.
This is why I've been so confused as to how to properly use it.
http://www.websiteoptimization.com/speed/tweak/def...
http://developer.yahoo.com/performance/rules.html#...