Skip to content
Henrik Vendelbo edited this page Apr 9, 2014 · 4 revisions

The default way for a script to be loaded into the page is while the page is being loaded. Regular HTML script tags are loaded one at a time as the page progresses loading.

Using EssentialJS other options are,

  • Lazy during page load (text/javascript)
  • After user authenticated (text/javascript+authenticated)
  • Before other lazy loaded scripts (text/javascript+preloading)

To use one of these options add a link element,

<link src="js/knockout.js" rel="subresource" type="text/javascript">

The script will be loaded by a dynamically added script tag. The script will be monitored and the page launching will be postponed until the script is loaded.

Language dependence

If you have a script for a specific locale, add a lang attribute. The Page State Language will determine if the script is loaded.

<link src="en/translations.js" lang="en" rel="subresource" type="text/javascript+preloading">
<link src="de/translations.js" lang="de" rel="subresourceswitch" type="text/javascript+preloading">

If the language is changed after the page is loaded the alternate script can be loaded and run if you add switch to the rel attribute.

Clone this wiki locally