Defer loading of JavaScript

Defer loading of JavaScript
<script type="text/javascript">
	// Add a script element as a child of the body
	function downloadJSAtOnload() {
	var element = document.createElement("script");
		element.src = "deferredfunctions.js";

	// Check for browser support of event handling capability
	if (window.addEventListener)
		window.addEventListener("load", downloadJSAtOnload, false);
	else if (window.attachEvent)
		window.attachEvent("onload", downloadJSAtOnload);
		window.onload = downloadJSAtOnload;

Deferring loading of JavaScript functions that are not called at startup reduces the initial download size, allowing other resources to be downloaded in parallel, and speeding up execution and rendering time.

Reference URL