I have created New page_layout empty.xml. I need to remove some JS and CSS from this layout.
I already try <remove src="print.css"/> But it gives an error Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'remove', attribute 'src': The attribute 'src' is not allowed.
app/design/frontend/Sm/market/Magento_Theme/page_layout/empty.xml
<?xml version="1.0"?>
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
<update handle="empty"/>
<referenceContainer name="head" remove="true"/>
<referenceContainer name="header" remove="true"/>
<referenceContainer name="menu" remove="true"/>
<referenceContainer name="notifications" remove="true"/>
<referenceContainer name="footer" remove="true"/>
<referenceContainer name="body" remove="true"/>
<remove src="print.css"/>
</layout>
1 Answer 1
Here is the best example to remove js or css using layout xml files.
<head>
<!-- Remove local styles resources -->
<remove src="css/styles-m.css" />
<remove src="<Namespace>_<ModuleName>::css/styles.css" />
<!-- Remove js resources -->
<remove src="my-js.js" />
<remove src="Magento_Catalog::js/sample1.js" />
<!-- Remove external resources -->
<remove src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css" />
<remove src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js" />
<remove src="http://fonts.googleapis.com/css?family=Montserrat" />
</head>
For more information, you can see here, Remove static links using layout
Please check like this and if this help you then hit like.
Thank you,
Hiren Patel
-
Your code will work for the layout file But I need the solution for the page_layout file.Pratik Kamani– Pratik Kamani2020年10月05日 05:39:29 +00:00Commented Oct 5, 2020 at 5:39