For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

Tuesday, May 05, 2015

How to load JavaScript file async in Magento

Problem:

By async loading JavaScript it will boost up your site, so how to load JavaScript file async in Magento.  In Magento there are two methods to load JavaScript .
1- By addItem
2-By addJs

Solution:

By using async option in <params>async</params> script tag you can load it.

Example:

Open your local.xml file it will be in the "app\design\frontend\default\YOUR-THEME-NAME\layout" folder.

1- By addItem
<action method="addItem">
    <type>skin_js</type>
    <name>js/jquery.mousewheel.min.js</name>
   <params>async</params>
</action>


2-By addJs
<action method="addJs">
     <script>scriptaculous/effects.js</script>
     <params>async</params>
</action>




Share:

0 comments:

Post a Comment

Unable to resolve <website url> Try checking the for validity Google Pagespeed Insights

Unable to resolve <website url> Try checking the for validity Google Pagespeed Insights   You have a website and want to test it'...

Ads Inside Post

Powered by Blogger.

Arsip