Back

The async and defer Script Attributes

About

In HTML5, script tags are allowed to bear two new attributes, async and defer which grant you greater control over how scripts are loaded and executed.

async

The async attribute instructs the JavaScript parser to load and run the given script asynchronously to the remaining JavaScript. This prevents scripts from blocking the load of the remaining webpage.

defer

The defer attribute instructs the JavaScript parser to wait to execute the script until the document has been completely loaded. This is akin to the $(document).ready(...) behavior available in jQuery.

References

  1. https://developer.mozilla.org/En/HTML/Element/Script