title: How to defer loading of JavaScript file?
body: <p>I don't want to call the JavaScript functions at the startup. The reason is simple, it will reduce the initial download size and the page will be appear faster. To do that I used the following code inside head section..</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
   // Add a script element as a child of the body
   function downloadJSAtOnload() {
   var element = document.createElement("script");
   element.src = "deferredfunctions.js";
   document.body.appendChild(element);
   }
  
   // Check for browser support of event handling capability
   if (window.addEventListener)
   window.addEventListener("load", downloadJSAtOnload, false);
   else if (window.attachEvent)
   window.attachEvent("onload", downloadJSAtOnload);
   else window.onload = downloadJSAtOnload;
  &lt;/script&gt;
  </code></pre>
  
  <p>But it did not work...please help me</p>