Reading list Switch to dark mode

    How to remove JS and CSS in Magento 2 using layout XML

    Updated 7 August 2018

    Sometimes, there is a need to remove some CSS and JS from a page as there may be conflictions between the theme and module CSS and JS.

    In order to remove CSS and JS from a page, <remove> tag is used in layout XML under the <head> tag.

    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <head>
            <remove src="name.css"/>
            <remove src="css/name.css"/>
            <remove src="js/name.js"/>
            <remove src="Vendor_Module::js/name.js"/>
        </head>
    </page>
    
    

    For more reference please visit the following link – https://devdocs.magento.com/guides/v2.2/frontend-dev-guide/layouts/xml-manage.html#layout_markup_css_remove

    Searching for an experienced
    Magento 2 Company ?
    Read More
    . . .
    Discuss on Helpdesk

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    2 comments

  • luenib
    How do I determine the path to the files I want to remove? In the case off “css/name.css” how come this path includes “css/” but not the path to “name.css”?

    Thanks.

    • Sagar Bathla (Moderator)
      This is just an example, the case “name.css” means it is kept inside the web folder and the case “css/name.css” it is kept inside web/css folder.
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home