Rating: Not Rated Yet

Javascript Async & Defer

Rating: Not Rated Yet
Downloaded 4 820 times

Improve your page loading time by allowing javascript loading asynchronously
You will see the difference with YSlow and Google Page speed ranking but your visitors will thank you for providing a speedy website.

When a browser loads a webpage, it will start by loading external Javascript and CSS ressources before loading the html and render it's content.

<script src="/foo/bar.js" type="text/javascript"></script>

If neither async or defer is present: The script is fetched and executed immediately, before the browser continues parsing the page

<script src="/foo/bar.js" defer="defer" type="text/javascript"></script>


If async is not present and defer is present: The script is executed when the page has finished parsing

<script src="/foo/bar.js" async="true" type="text/javascript"></script>


If async is present: The script is executed asynchronously with the rest of the page (the script will be executed while the page continues the parsing)

This will improve your global page loading time as illustrated below

javascript-sequence

 However, this is not applicable to all scripts as you want to make sure the script is loaded while some other script or inline script will call it.

Usually, if your jQuery inline scripts are called within a jQuery(document).ready() declaration, you can safely load the javascript file asynchronously.

Google Page Speed Insights : Use Asynchronous Scripts

Yahoo YSlow : Put Javascript at bottom

Usage

Install and publish the plugin. In the "scripts to modify" field, enter the path to the scripts to be loaded either in async or defer.
For example, you can enter '/modules/mod_rokajaxsearch/js/rokajaxsearch.js'
Add one script per line

Limitations

This applies only to scripts that were added via Joomla using Joomla way. Please refer to this documentation

JFactory::getDocument()->addScript('/modules/mod_rokajaxsearch/js/rokajaxsearch.js');

This will not work with scripts that were added inline or loaded by another javascript.

VersionRelease notesDate
1.0.0- Initial release2013-09-30


There are yet no reviews for this product.
Top