I have tried to load js asynchronously in Magento 2 following a recommendation from the Google PageSpeed Insights tool. Unfortunately my updates in the relevant layout file break the page.


 <script async src="js::myown.js"/>
 <script async src="js::another.js"/>
 <script async src="js::afinal.js"/>

Can someone please recommend a solution to the above to get the async loading working?

  • I recommend looking at using require.js to add your scripts, here is a good article explaining it.
    – Ben Crook
    Commented May 2, 2017 at 8:24

1 Answer 1


Try attribute async="async" between script tag

<script async="async" src="Vendor_ModuleName::js/your.own.js"/>

or in theme

<script async="async" src="js/your.own.js"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.