I tried below step to merge and minify js and css

bin/magento setup:upgrade

bin/magento indexer:reindex

bin/magento deploy:mode:set production -s

php bin/magento setup:di:compile-multi-tenant

bin/magento setup:static-content:deploy

when I open the website in browser along with merged file I can see all other js file also loading

enter image description here

please help me out

in admin side

Enable Javascript Bundling :- Yes

Merge JavaScript Files :- Yes.

Minify JavaScript Files :- Yes

  • The way RequireJS works in Magento 2 is it (usually) loads the scripts only when required, so a certain script won't load until a certain element has loaded in the DOM. By doing this I'm not sure how merging JS would work, for example if you were to merge all JS files and then load an element in the DOM that required a script how could that be merged into the rest of the merged JS? Because of this I'm not sure how possible it is to merge all JS loaded via RequireJS.
    – Ben Crook
    Commented Oct 14, 2016 at 9:52
  • Hi @Pradeep Kumar did you get any solution? Facing same issue in Magento 2.1.2 CE Version
    – Jackson
    Commented Nov 23, 2016 at 5:22
  • @AnkitShah :- check my latest answer Commented Nov 23, 2016 at 10:23
  • @BenCrook I have not yet understood so well how "Enable javascript Boundling" works, I have many doubt about that. But I think that with this config active the server itself create the bundles, not requireJS.
    – nuovecode
    Commented Mar 17, 2017 at 15:07

4 Answers 4


You can't cleared the static files. I'm not quite sure if setup static:deploy does that (I never use it for changes like this)

And also, perhaps developer mode would help? php bin/magento deploy:mode:set developer

I'd try deleting the static & var folders Remove pub/static Remove var/cache Remove var/composer_home Remove var/generation Remove var/page_cache Remove var/view_preprocessed


I have the similar issue. The cause for no image is because there is an error in JS file after minify JS. You can verify it in your browser (firebug etc).

.../div>';return __p};})(window,document,location,typeof jQuery!=='undefined'&&jQu

I solved this by remove all the file in var/cache/ and pub/static/ and setup:static-content:deploy again

But there is still another issue, it's about the braintree if you enable it. Braintree doesn't show up due to another JS error.

Error: Script error for: https://js.braintreegateway.com/v2/braintree.js http://requirejs.org/docs/errors.html#scripterror

...Error(id,msg,err,requireModules){var e=new Error(msg+'\nhttp://requirejs.org/doc...

For now, I simply don't use the minify js function to avoid the trouble until solution is found.


Below are the steps i followed for merged and minify and it works for me

  1. in admin Enable Javascript Bundling :- Yes Merge JavaScript Files :- Yes. Minify JavaScript Files :- Yes and also CSS
  2. set production mode You have to set production mode in htacces or ngnix configuration that is SetEnv MAGE_MODE production (.htaccess)

    set $MAGE_MODE production; (ngnix cong file)

  3. clear cache and run php bin/magento setup:static-content:deploy
    if you have multi locale than run enlish last that is

    php bin/magento setup:static-content:deploy ar_KW en_US


Please check your pub/static folder. Maybe the www-data group doesn't have a write permision to create _cache folder. I've deleted static folder manually in command line. Therefore it can not create _cache folder.

Take a look at var/log/exceptions.log: tail -f var/log/exception.log In my case:

[2020-09-26 12:28:24] main.CRITICAL: Le répertoire "/data/var/www/preprod/www/pub/static/_cache" ne peut être crée Warning!mkdir(): Permission denied {"exception":"[object] (Magento\\Framework\\Exception\\FileSystemException(code: 0): Le répertoire \"/data/var/www/vgc-preprod/www/pub/static/_cache\" ne peut être crée Warning!mkdir(): Permission denied at /data/var/www/preprod/www/vendor/magento/framework/Filesystem/Driver/File.php:227)"}


chmod 777 -r pub/static

Hope it can help.

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.