« Home | Chess rules » | A good recent game that I won. » | Detecting php duplicate and unused code. » | javascript functions. » | Create tunnel via the ssh command in linux. » | Find tables which are empty in database. » | Svn branching strategies. » | Excellent tutorial on linux usermanagement and sud... » | Using Grep to search in files » | Android implicit intents various intents creation ... » 

Sunday, November 06, 2011 

Loading scripts asynchronously.

Was checking ways to asynchronously load javascript files in the page.
Came across these two excellent blogs - http://www.stevesouders.com/blog/2009/04/27/loading-scripts-without-blocking/

There are six main techniques for downloading scripts without blocking:
  • XHR Eval – Download the script via XHR and eval() the responseText.
  • XHR Injection – Download the script via XHR and inject it into the page by creating a script element and setting its text property to the responseText.
  • Script in Iframe – Wrap your script in an HTML page and download it as an iframe.
  • Script DOM Element – Create a script element and set its src property to the script’s URL.
  • Script Defer – Add the script tag’s defer attribute. This used to only work in IE, but is now in Firefox 3.1.
  • document.write Script Tag – Write the