How to add external js/css/link in magento2

Magento are handle script and css load in head section by layout xml, almost source are loaded from the local, but if some time we want to add external script or css link to our store, external script/source can be 3rd party or external CDN services, here is the guide to do it.

Add this element inside head section of your layout update, you can add in xml layout files or in backend layout update settings, we can add external script/css/link:

Just Simple add the src_type=”url” attribute to the element you want to external.

Maybe loading external script/source can affect your site speed so add async attribute is a good idea, just add async=”true” to the element you want to async loading


If you are a developer you can dig into the code that handle render head block at: