Magento 2, PHP

Magento 2: Remove static resources

To remove the static resources, linked in a page <head>, make a change similar to the following in a theme extending file:

<page xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <!-- Remove local resources -->
        <remove src="css/styles-m.css" />
        <remove src="my-js.js"/>
        <remove src="Magento_Catalog::js/compare.js" />
	<!-- Remove external resources -->
        <remove src=""/>
        <remove src=""/>
        <remove src="" /> 

Note, that if a static asset is added with a module path (for example Magento_Catalog::js/sample.js) in the initial layout, you need to specify the module path as well when removing the asset.


Tags :