I searched for an answer, but I didn't find one. I like to enable js merging and compressing in Magento 2 developer mode. Is this possible? I enabled them in admin, but the merging is not working enter image description here


1 Answer 1


I never tried to do anything like this, but the magento mode, before js merging, seems to be detected at:

vendor/magento/framework/View/Asset/MergeService.php line 84

Actually it also seems to do some merging stuff in developer mode, but on a different way. In developer mode it merges js files by: Magento\Framework\View\Asset\MergeStrategy\Checksum

In all other modes the js files are merged by: Magento\Framework\View\Asset\MergeStrategy\FileExists

Means in developer mode, it compares all the files it wants to merge, to some other file, where it stores the last modified time of the files to merge. And only if files were modified, the merging will be done.

For further information about how merging of JS/CSS works, this link is kinda helpful, it also explains how to set it up and where limitations are. https://mirasvit.com/knowledge-base/how-to-combine-javascript-files-in-magento-2.html

JS Bundling:

The thing, which does only work in production mode is not the JS merging, but the JS bundling. Here is the official Magento doc about JS bundling: https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/themes/js-bundling.html

there the mode is detected inside the createStaticJsAsset method of vendor/module-require-js/Model/FileManager.php. Feel free to try to implement an plugin for this method, and share with us if there were more steps to achieve JS bundling in developer mode.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.