1

I have some code error due to upgrade in Magento 2 but my goal is to minify js. Till now I know that we can not minify js without correcting error of the code in magento but I want to know some trick some realy awesome trick to minify js even I have some issue in the code.

0

I think all that you need is enable "Enable JavaScript Bundling" and "Minify JavaScript Files" options in system configuration on website level in System Configuration > ADVANCED > Developer > JavaScript Settings section and redeploy static content

  • sorry i think you dont understand the question or maybe i didnt explain it correctly . when i minify js in developer mode and after i switch to production mode then js is not minified because there is some error in the code .. i dont want to remove the error i want to minify it only . – Flutterer Sep 28 '18 at 22:07
0

Go to admin panel Stores -> Configuration -> Advanced -> Developer . You will find option to enable js minification, choose it to be Yes (This option will be visible only if your developer mode is enabled.) . In your Magento 2 ssh console run the below command to set production mode if it is not set, because minification works only in production mode:

bin/magento deploy:mode:set production --skip-compilation

Note: --skip-compilation command is not mandatory, use it if you want skip compilation, i would recommend you to not skip it. Then run the below commands:

bin/magento cache:clean
bin/magento setup:upgrade
bin/magento setup:static-content:deploy
  • sorry i think you dont understand the question or maybe i didnt explain it correctly . when i minify js in developer mode and after i switch to production mode then js is not minified because there is some error in the code .. i dont want to remove the error i want to minify it only . – Flutterer Sep 28 '18 at 22:07
  • Please post your error message and file name in the question. – Sourabh Kumar Sharma Sep 29 '18 at 4:46
  • there is no way to minify js without debuging the error ? – Flutterer Sep 29 '18 at 18:08
  • How can we help until you show us your error. – Sourabh Kumar Sharma Sep 29 '18 at 19:36
  • prntscr.com/l09ptk – Flutterer Sep 29 '18 at 20:21
0

To merge JavaScript files in Magento 2:

Navigate to Admin panel > Stores > Configuration > Advanced > Developer

Open the JavaScript Settings section and in the Minify JavaScript Files field, select Yes.

When complete, click Save Config.


If the above solution is not working for you due to some bugs or errors, I would try this gulp solution

Take a look at this: How to minify/optimise Javascript on Magento 2?

Although, I would strongly recommend fixing the error.

  • ok i will think about removing the error but for now i am trying to minify it . if nothing helped me out then will do something like that . – Flutterer Sep 28 '18 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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