<script type="text/javascript"> function downloadJSAtOnload() { var element = document.createElement("script"); element.src = "defer.js"; document.body.appendChild(element); } if (window.addEventListener) window.addEventListener("load", downloadJSAtOnload, false); else if (window.attachEvent) window.attachEvent("onload", downloadJSAtOnload); else window.onload = downloadJSAtOnload; </script>
Computer, Technology, Databases, Google, Internet, Mobile, Linux, Microsoft, Open Source, Security, Social Media, Web Development, Business, Finance
Wednesday, January 01, 2014
How to defer loading of javascript efficiently using the Google way?
If there is a piece of code that is intended to be loaded after a webpage finishes loading, one efficient method as recommended by Google is to use listeners. An article on feedthebot illustrates the Google's method. The following code should be placed in your HTML just before the </body> tag. Also, all code blocks supposed to be delayed are to be placed in an external js file (defer.js in this case).
Subscribe to:
Post Comments (Atom)
Popular Posts
-
Google url shortener service, goo.gl , is now much improved with newly included features like easier copy and paste, and ability to delete e...
-
I would like to apologize that sigining of my guestbook is not possible at the moment due to an unexpected bug. There is already 74 entries ...
-
The Google Adsense made a blog post with a video to help us understand the concept behind eCPM (Effective Cost Per Thousand Impressions). ...
-
Below class, written by myself, will validate a XML file based on its XSD file using .NET 2.0 technology. Please note .NET 1.1 is not compat...
-
An efficient method to find out the total record counts of all tables in an Oracle database. select table_name, to_number(extractvalue(xm...
No comments:
Post a Comment
Do provide your constructive comment. I appreciate that.