0

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>
asked Oct 2, 2020 at 8:00

1 Answer 1

0

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

answered Oct 2, 2020 at 8:51
1
  • Your code will work for the layout file But I need the solution for the page_layout file. Commented Oct 5, 2020 at 5:39

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.