Magento, Magento 2

How to Add External CSS and JS in Magento 2

How to Add External CSS and JS in Magento 2

In this tutorial, Today I will explain to how to add external css and js in Magento 2. If you want to add third party css or js into your module or theme then, you need to use src_type=”url” attribute using this below way :

You may also like this :

For add CSS third party :


<head>
     <css src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.css" src_type="url" />
</head>

For add JS third party :


<head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.js" src_type="url" />
</head>

You can use these above format in your xml file. You can add third party cdn js and css file using this way into your module or custom theme.

That’s it !!!

I hope this blog is easy to understand how to add external css and js in Magento 2. In case, I missed anything or need to add some information, always feel free to leave a comment in this blog, I’ll get back with a proper solution.

Stay Safe and Stay Connected !!

Tagged ,