0

I have enabled js and css merging and bundling from the configuration.
we can remove particular js or css using below code.

<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="js/name.js"/>
 <remove src="Vendor_Module::js/name.js"/>
 </head>
</page>

But when i try same for removing merged js or css file it is not working, is there any other way to remove that merged css and js files from layout or any other way.

asked Apr 8, 2019 at 12:07
2
  • So do you want to exclude those files or you trying something else? Commented Apr 8, 2019 at 12:14
  • actually, I want to let merge enabled and want to remove those merged js and CSS file. Commented Apr 8, 2019 at 12:25

2 Answers 2

2

Exclude js file from the bundle by adding the js file in Theme_Directory/etc/view.xml

<exclude>
<item type="file">Mage_Storelocator::js/googlemap.min.js</item>
</exclude>

Exclude js file from minification in config.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
 <default>
 <dev>
 <js>
 <minify_exclude>
 <tiny_mce>
 /tiny_mce/
 </tiny_mce>
 </minify_exclude>
 </js>
 </dev>
 </default>
</config>

You have not excluded the files but you have removed them.

So to exclude the files specified by you from merging/bundling you can add those files to exclude list in your Theme_Directory/etc/view.xml so that they can be loaded individually

<exclude>
 <item type="file">Module_Name::css/name.css</item>
 <item type="file">Module_Name::js/name.js</item>
 <item type="file">Vendor_Module::js/name.js</item>
</exclude>

So if you have minified your files please specify the file name as css/name.min.css or js/name.min.js

enter image description here

I have enabled minification and merge in Magento 2.3.1 and I have excluded this file which is loading separately rather than merge file

<item type="file">Magento_Catalog::js/product/list/toolbar.min.js</item>
answered Apr 8, 2019 at 14:08
1

You Can Disable Merge Js Or Css Using Admin Backend:-

Js Merge

Store > Configration > Advanced > Developer > JavaScript Settings > Merge JavaScript Files > Set Yes

CSS Merge

Store > Configration > Advanced > Developer > CSS Settings > Merge CSS Files > Set Yes
answered Apr 8, 2019 at 12:12
2
  • actually, I want to let merge enabled and want to remove those merged js and CSS file. Commented Apr 8, 2019 at 12:25
  • ohk check your js and css file and try to s:up , s:s:d -f and cache clean Commented Apr 8, 2019 at 12:32

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.