You can save JavaScript loading time by minimizing JavaScript in the initial page. To do this use on-demand JavaScript loading to download JavaScript only when it is required.

If you divide large JavaScript file into several smaller files, only some of those files are needed to generate the initial page. Later, you can load other JavaScript files by inserting script element as follows:

Main.onLoad=function(){varwidgetAPI=newCommon.API.Widget();widgetAPI.sendReadyEvent();setTimeout('IncludeJavascript()',0);}functionIncludeJavaScript(){varhead=document.getElementsByTagName('head')[0];varscript=document.createElement('script');//script tag creation.script.type='text/javascript';script.src='test.js';script.onload=function(){//your code here - will be run when your js file is loaded};head.appendChild(script);//inject a new script element into page}

The browser loads an image for an element’s background style when its background style matching is invoked. Deleting background style of some elements which are not necessary in the initial page can reduce the application loading time.

Later, when it is required, you can apply an element’s background style as follows: