Merged JS and CSS do not work when Production mode












23















I was in developer mode, everything was great, when I changed to Production mode, the Merged options of CSS and JS seem to be ignored, it was back listing all css and js.



Also the product page only shows the pictures of the product in developer mode, after changing to production mode they disappear.



Any thought to help me?





The point is, I'm doing it.



Here is what I did in sequence:



bin/magento setup:upgrade

bin/magento indexer:reindex

bin/magento setup:static-content:deploy

bin/magento setup:di:compile

bin/magento deploy:mode:set production

bin/magento setup:static-content:deploy


And before even starting, the Merge options are YES and I was in developer mode.










share|improve this question

























  • Hello, Have you got any solution of this issue, I am getting same issue in magento 2.0.7. Please give the solution if you have any, Thanks

    – Ashish Jagnani
    Oct 3 '16 at 9:36
















23















I was in developer mode, everything was great, when I changed to Production mode, the Merged options of CSS and JS seem to be ignored, it was back listing all css and js.



Also the product page only shows the pictures of the product in developer mode, after changing to production mode they disappear.



Any thought to help me?





The point is, I'm doing it.



Here is what I did in sequence:



bin/magento setup:upgrade

bin/magento indexer:reindex

bin/magento setup:static-content:deploy

bin/magento setup:di:compile

bin/magento deploy:mode:set production

bin/magento setup:static-content:deploy


And before even starting, the Merge options are YES and I was in developer mode.










share|improve this question

























  • Hello, Have you got any solution of this issue, I am getting same issue in magento 2.0.7. Please give the solution if you have any, Thanks

    – Ashish Jagnani
    Oct 3 '16 at 9:36














23












23








23


8






I was in developer mode, everything was great, when I changed to Production mode, the Merged options of CSS and JS seem to be ignored, it was back listing all css and js.



Also the product page only shows the pictures of the product in developer mode, after changing to production mode they disappear.



Any thought to help me?





The point is, I'm doing it.



Here is what I did in sequence:



bin/magento setup:upgrade

bin/magento indexer:reindex

bin/magento setup:static-content:deploy

bin/magento setup:di:compile

bin/magento deploy:mode:set production

bin/magento setup:static-content:deploy


And before even starting, the Merge options are YES and I was in developer mode.










share|improve this question
















I was in developer mode, everything was great, when I changed to Production mode, the Merged options of CSS and JS seem to be ignored, it was back listing all css and js.



Also the product page only shows the pictures of the product in developer mode, after changing to production mode they disappear.



Any thought to help me?





The point is, I'm doing it.



Here is what I did in sequence:



bin/magento setup:upgrade

bin/magento indexer:reindex

bin/magento setup:static-content:deploy

bin/magento setup:di:compile

bin/magento deploy:mode:set production

bin/magento setup:static-content:deploy


And before even starting, the Merge options are YES and I was in developer mode.







magento2 javascript css






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 5 mins ago









guaka

1113




1113










asked Mar 15 '16 at 22:27









BrunoBuenoBrunoBueno

7133926




7133926













  • Hello, Have you got any solution of this issue, I am getting same issue in magento 2.0.7. Please give the solution if you have any, Thanks

    – Ashish Jagnani
    Oct 3 '16 at 9:36



















  • Hello, Have you got any solution of this issue, I am getting same issue in magento 2.0.7. Please give the solution if you have any, Thanks

    – Ashish Jagnani
    Oct 3 '16 at 9:36

















Hello, Have you got any solution of this issue, I am getting same issue in magento 2.0.7. Please give the solution if you have any, Thanks

– Ashish Jagnani
Oct 3 '16 at 9:36





Hello, Have you got any solution of this issue, I am getting same issue in magento 2.0.7. Please give the solution if you have any, Thanks

– Ashish Jagnani
Oct 3 '16 at 9:36










10 Answers
10






active

oldest

votes


















19














I just did the following and the problem was solved:




bin/magento setup:upgrade

bin/magento indexer:reindex

bin/magento deploy:mode:set production -s

# Here was the secret: run the di:compile after production
bin/magento setup:di:compile

bin/magento setup:static-content:deploy





share|improve this answer





















  • 2





    i tried same way but no luck

    – Pradeep Kumar
    May 31 '16 at 8:30













  • This worked for me.

    – dchayka
    Jan 10 '17 at 15:55











  • If i execute command "production -s" it blank my site and give very unusal error: Warning: include(/siteRoot/html/var/view_preprocessed/html/vendor/magento/module-theme/view/base/templates/root.phtml): failed to open stream: No such file or directory in /siteRoot/html/vendor/magento/framework/View/Result/Page.php on line 312

    – Jai
    Feb 24 '17 at 9:25











  • Another - that worked for me. In case anyone else is having the problem I was. CSS would minify and bundle, but JS would not, despite having the options enabled in the admin. Adding the -s in the set product mode made all the difference. Also, the backend is MUCH faster now as well. I was using the same order and commands, but it was the "-s" that made the difference, Thank you

    – dawhoo
    Mar 26 '17 at 20:31











  • Do i first need to switch back to development mode? I did what you mentioned, but no difference....

    – Jilco Tigchelaar
    Jul 24 '17 at 18:22



















1














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.






share|improve this answer































    1














    These are the steps that worked for me on Magento ver. 2.1.7 with Redis (not running Varnish). However, it's still unclear if everything is working as it should. JS is minified and bundled (unclear what merge is supposed to do). CSS is minified (not seeing it merged).




    1. Turn off all Magento cache.

    2. Clear redis cache.

    3. Turn all five css/js configs on (either in admin or via database).

    4. Generate static files.

    5. Clear Magento cache (command line). For safety (may not be required).

    6. Clear opcache (if not set to auto refresh).

    7. Refresh frontend home page (and check browser console for errors).

    8. Turn on Magento cache.


    dev/css/merge_css_files = 1
    dev/css/minify_files = 1
    dev/js/enable_js_bundling = 1
    dev/js/merge_files = 1
    dev/js/minify_files = 1



    Simply turning on the configs and clearing cache didn't work -- the frontend browser console reported a lot of js errors.






    share|improve this answer


























    • Merge will merge your files together into one.

      – ladle3000
      Oct 5 '18 at 13:45



















    0














    Have you tried to flush the JavaScript/CSS? You can do this under System>Cache Management and then press the button which is on the bottom of the table on the left 'Flus JavaScript/CSS Cache'






    share|improve this answer
























    • YEP.... flush js, then cache. Nothing change. However, if I switch to Developer mode, the merge works.

      – BrunoBueno
      Mar 16 '16 at 17:03



















    0














    You need to redeploy static after enabling this option in production mode.






    share|improve this answer
























    • The point is, I'm doing it. I just posted here what I did.

      – BrunoBueno
      Mar 16 '16 at 17:02













    • If it not works then problem maybe in in permission. Can you check your webserver access/errors log

      – KAndy
      Mar 17 '16 at 14:01



















    0














    Make sure you check your NGINX configuration file as well.



    If there is a variable $MAGE_MODE set there it needs to be changed to production as well, and save the file



    After that you will need to reload or restart NGINX depending on your preference.



    sudo service nginx reload


    OR



    sudo service nginx restart


    After that check your app/etc/env.php and see if the MAGE_MODE array key is set to production as well if not change it to production or you can use the command



    php bin/magento deploy:mode:set production


    After you executed the command check if the value changed app/etc/env.php, sometimes there might be permission issues.



    Next, clean out the pub/static folder.



    rm -rf pub/static/*


    Clear/Flush your cache



    php bin/magento cache:clean
    php bin/magento cache:flush


    Now you are ready to execute the static content deploy



    php bin/magento setup:static-content:deploy


    Hope this helps.






    share|improve this answer































      0














      I just did the following and the problem was solved.



      bin/magento setup:upgrade

      bin/magento indexer:reindex

      bin/magento deploy:mode:set production -s

      bin/magento setup:di:compile


      (Here was the secret, to run the di:compile after production)



      bin/magento setup:static-content:deploy





      share|improve this answer

































        0
















        1. Please also enable "Enable JavaScript Bundling" option



          store->configuration->advanced->developer->javascript setting->



        2. Enable JavaScript Bundling set to "yes" And flush cache







        share|improve this answer





















        • 1





          Haphazard advice that has nothing to do with the question.

          – ladle3000
          Oct 5 '18 at 13:46



















        0














        I've had the problem when the JavaScript is un-compiled the jquery selector works.




        $('#my_element').click(function(){ alert('Hello World');});


        But once compiled, compressed and joined, I then need to code:-




        $('body #my_element').click(function(){ alert('Hello World');});


        Don't ask why, it seems that when reading directly from the cache, the requirejs code executes before the domReady and the elements attach to different elements in some different page.






        share|improve this answer































          -1














          Delete cache manually var/cache and delete session manually var/session






          share|improve this answer



















          • 1





            Deleting var/session is never an appropiate solution. magento.stackexchange.com/questions/94589/…

            – Fabian Schmengler
            Sep 14 '16 at 10:42











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "479"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f106436%2fmerged-js-and-css-do-not-work-when-production-mode%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          10 Answers
          10






          active

          oldest

          votes








          10 Answers
          10






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          19














          I just did the following and the problem was solved:




          bin/magento setup:upgrade

          bin/magento indexer:reindex

          bin/magento deploy:mode:set production -s

          # Here was the secret: run the di:compile after production
          bin/magento setup:di:compile

          bin/magento setup:static-content:deploy





          share|improve this answer





















          • 2





            i tried same way but no luck

            – Pradeep Kumar
            May 31 '16 at 8:30













          • This worked for me.

            – dchayka
            Jan 10 '17 at 15:55











          • If i execute command "production -s" it blank my site and give very unusal error: Warning: include(/siteRoot/html/var/view_preprocessed/html/vendor/magento/module-theme/view/base/templates/root.phtml): failed to open stream: No such file or directory in /siteRoot/html/vendor/magento/framework/View/Result/Page.php on line 312

            – Jai
            Feb 24 '17 at 9:25











          • Another - that worked for me. In case anyone else is having the problem I was. CSS would minify and bundle, but JS would not, despite having the options enabled in the admin. Adding the -s in the set product mode made all the difference. Also, the backend is MUCH faster now as well. I was using the same order and commands, but it was the "-s" that made the difference, Thank you

            – dawhoo
            Mar 26 '17 at 20:31











          • Do i first need to switch back to development mode? I did what you mentioned, but no difference....

            – Jilco Tigchelaar
            Jul 24 '17 at 18:22
















          19














          I just did the following and the problem was solved:




          bin/magento setup:upgrade

          bin/magento indexer:reindex

          bin/magento deploy:mode:set production -s

          # Here was the secret: run the di:compile after production
          bin/magento setup:di:compile

          bin/magento setup:static-content:deploy





          share|improve this answer





















          • 2





            i tried same way but no luck

            – Pradeep Kumar
            May 31 '16 at 8:30













          • This worked for me.

            – dchayka
            Jan 10 '17 at 15:55











          • If i execute command "production -s" it blank my site and give very unusal error: Warning: include(/siteRoot/html/var/view_preprocessed/html/vendor/magento/module-theme/view/base/templates/root.phtml): failed to open stream: No such file or directory in /siteRoot/html/vendor/magento/framework/View/Result/Page.php on line 312

            – Jai
            Feb 24 '17 at 9:25











          • Another - that worked for me. In case anyone else is having the problem I was. CSS would minify and bundle, but JS would not, despite having the options enabled in the admin. Adding the -s in the set product mode made all the difference. Also, the backend is MUCH faster now as well. I was using the same order and commands, but it was the "-s" that made the difference, Thank you

            – dawhoo
            Mar 26 '17 at 20:31











          • Do i first need to switch back to development mode? I did what you mentioned, but no difference....

            – Jilco Tigchelaar
            Jul 24 '17 at 18:22














          19












          19








          19







          I just did the following and the problem was solved:




          bin/magento setup:upgrade

          bin/magento indexer:reindex

          bin/magento deploy:mode:set production -s

          # Here was the secret: run the di:compile after production
          bin/magento setup:di:compile

          bin/magento setup:static-content:deploy





          share|improve this answer















          I just did the following and the problem was solved:




          bin/magento setup:upgrade

          bin/magento indexer:reindex

          bin/magento deploy:mode:set production -s

          # Here was the secret: run the di:compile after production
          bin/magento setup:di:compile

          bin/magento setup:static-content:deploy






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 5 mins ago









          guaka

          1113




          1113










          answered Mar 16 '16 at 17:23









          BrunoBuenoBrunoBueno

          7133926




          7133926








          • 2





            i tried same way but no luck

            – Pradeep Kumar
            May 31 '16 at 8:30













          • This worked for me.

            – dchayka
            Jan 10 '17 at 15:55











          • If i execute command "production -s" it blank my site and give very unusal error: Warning: include(/siteRoot/html/var/view_preprocessed/html/vendor/magento/module-theme/view/base/templates/root.phtml): failed to open stream: No such file or directory in /siteRoot/html/vendor/magento/framework/View/Result/Page.php on line 312

            – Jai
            Feb 24 '17 at 9:25











          • Another - that worked for me. In case anyone else is having the problem I was. CSS would minify and bundle, but JS would not, despite having the options enabled in the admin. Adding the -s in the set product mode made all the difference. Also, the backend is MUCH faster now as well. I was using the same order and commands, but it was the "-s" that made the difference, Thank you

            – dawhoo
            Mar 26 '17 at 20:31











          • Do i first need to switch back to development mode? I did what you mentioned, but no difference....

            – Jilco Tigchelaar
            Jul 24 '17 at 18:22














          • 2





            i tried same way but no luck

            – Pradeep Kumar
            May 31 '16 at 8:30













          • This worked for me.

            – dchayka
            Jan 10 '17 at 15:55











          • If i execute command "production -s" it blank my site and give very unusal error: Warning: include(/siteRoot/html/var/view_preprocessed/html/vendor/magento/module-theme/view/base/templates/root.phtml): failed to open stream: No such file or directory in /siteRoot/html/vendor/magento/framework/View/Result/Page.php on line 312

            – Jai
            Feb 24 '17 at 9:25











          • Another - that worked for me. In case anyone else is having the problem I was. CSS would minify and bundle, but JS would not, despite having the options enabled in the admin. Adding the -s in the set product mode made all the difference. Also, the backend is MUCH faster now as well. I was using the same order and commands, but it was the "-s" that made the difference, Thank you

            – dawhoo
            Mar 26 '17 at 20:31











          • Do i first need to switch back to development mode? I did what you mentioned, but no difference....

            – Jilco Tigchelaar
            Jul 24 '17 at 18:22








          2




          2





          i tried same way but no luck

          – Pradeep Kumar
          May 31 '16 at 8:30







          i tried same way but no luck

          – Pradeep Kumar
          May 31 '16 at 8:30















          This worked for me.

          – dchayka
          Jan 10 '17 at 15:55





          This worked for me.

          – dchayka
          Jan 10 '17 at 15:55













          If i execute command "production -s" it blank my site and give very unusal error: Warning: include(/siteRoot/html/var/view_preprocessed/html/vendor/magento/module-theme/view/base/templates/root.phtml): failed to open stream: No such file or directory in /siteRoot/html/vendor/magento/framework/View/Result/Page.php on line 312

          – Jai
          Feb 24 '17 at 9:25





          If i execute command "production -s" it blank my site and give very unusal error: Warning: include(/siteRoot/html/var/view_preprocessed/html/vendor/magento/module-theme/view/base/templates/root.phtml): failed to open stream: No such file or directory in /siteRoot/html/vendor/magento/framework/View/Result/Page.php on line 312

          – Jai
          Feb 24 '17 at 9:25













          Another - that worked for me. In case anyone else is having the problem I was. CSS would minify and bundle, but JS would not, despite having the options enabled in the admin. Adding the -s in the set product mode made all the difference. Also, the backend is MUCH faster now as well. I was using the same order and commands, but it was the "-s" that made the difference, Thank you

          – dawhoo
          Mar 26 '17 at 20:31





          Another - that worked for me. In case anyone else is having the problem I was. CSS would minify and bundle, but JS would not, despite having the options enabled in the admin. Adding the -s in the set product mode made all the difference. Also, the backend is MUCH faster now as well. I was using the same order and commands, but it was the "-s" that made the difference, Thank you

          – dawhoo
          Mar 26 '17 at 20:31













          Do i first need to switch back to development mode? I did what you mentioned, but no difference....

          – Jilco Tigchelaar
          Jul 24 '17 at 18:22





          Do i first need to switch back to development mode? I did what you mentioned, but no difference....

          – Jilco Tigchelaar
          Jul 24 '17 at 18:22













          1














          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.






          share|improve this answer




























            1














            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.






            share|improve this answer


























              1












              1








              1







              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.






              share|improve this answer













              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.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Jun 18 '16 at 8:47









              NeroNero

              387520




              387520























                  1














                  These are the steps that worked for me on Magento ver. 2.1.7 with Redis (not running Varnish). However, it's still unclear if everything is working as it should. JS is minified and bundled (unclear what merge is supposed to do). CSS is minified (not seeing it merged).




                  1. Turn off all Magento cache.

                  2. Clear redis cache.

                  3. Turn all five css/js configs on (either in admin or via database).

                  4. Generate static files.

                  5. Clear Magento cache (command line). For safety (may not be required).

                  6. Clear opcache (if not set to auto refresh).

                  7. Refresh frontend home page (and check browser console for errors).

                  8. Turn on Magento cache.


                  dev/css/merge_css_files = 1
                  dev/css/minify_files = 1
                  dev/js/enable_js_bundling = 1
                  dev/js/merge_files = 1
                  dev/js/minify_files = 1



                  Simply turning on the configs and clearing cache didn't work -- the frontend browser console reported a lot of js errors.






                  share|improve this answer


























                  • Merge will merge your files together into one.

                    – ladle3000
                    Oct 5 '18 at 13:45
















                  1














                  These are the steps that worked for me on Magento ver. 2.1.7 with Redis (not running Varnish). However, it's still unclear if everything is working as it should. JS is minified and bundled (unclear what merge is supposed to do). CSS is minified (not seeing it merged).




                  1. Turn off all Magento cache.

                  2. Clear redis cache.

                  3. Turn all five css/js configs on (either in admin or via database).

                  4. Generate static files.

                  5. Clear Magento cache (command line). For safety (may not be required).

                  6. Clear opcache (if not set to auto refresh).

                  7. Refresh frontend home page (and check browser console for errors).

                  8. Turn on Magento cache.


                  dev/css/merge_css_files = 1
                  dev/css/minify_files = 1
                  dev/js/enable_js_bundling = 1
                  dev/js/merge_files = 1
                  dev/js/minify_files = 1



                  Simply turning on the configs and clearing cache didn't work -- the frontend browser console reported a lot of js errors.






                  share|improve this answer


























                  • Merge will merge your files together into one.

                    – ladle3000
                    Oct 5 '18 at 13:45














                  1












                  1








                  1







                  These are the steps that worked for me on Magento ver. 2.1.7 with Redis (not running Varnish). However, it's still unclear if everything is working as it should. JS is minified and bundled (unclear what merge is supposed to do). CSS is minified (not seeing it merged).




                  1. Turn off all Magento cache.

                  2. Clear redis cache.

                  3. Turn all five css/js configs on (either in admin or via database).

                  4. Generate static files.

                  5. Clear Magento cache (command line). For safety (may not be required).

                  6. Clear opcache (if not set to auto refresh).

                  7. Refresh frontend home page (and check browser console for errors).

                  8. Turn on Magento cache.


                  dev/css/merge_css_files = 1
                  dev/css/minify_files = 1
                  dev/js/enable_js_bundling = 1
                  dev/js/merge_files = 1
                  dev/js/minify_files = 1



                  Simply turning on the configs and clearing cache didn't work -- the frontend browser console reported a lot of js errors.






                  share|improve this answer















                  These are the steps that worked for me on Magento ver. 2.1.7 with Redis (not running Varnish). However, it's still unclear if everything is working as it should. JS is minified and bundled (unclear what merge is supposed to do). CSS is minified (not seeing it merged).




                  1. Turn off all Magento cache.

                  2. Clear redis cache.

                  3. Turn all five css/js configs on (either in admin or via database).

                  4. Generate static files.

                  5. Clear Magento cache (command line). For safety (may not be required).

                  6. Clear opcache (if not set to auto refresh).

                  7. Refresh frontend home page (and check browser console for errors).

                  8. Turn on Magento cache.


                  dev/css/merge_css_files = 1
                  dev/css/minify_files = 1
                  dev/js/enable_js_bundling = 1
                  dev/js/merge_files = 1
                  dev/js/minify_files = 1



                  Simply turning on the configs and clearing cache didn't work -- the frontend browser console reported a lot of js errors.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jul 28 '17 at 4:46

























                  answered Jul 26 '17 at 6:11









                  Aydus-MatthewAydus-Matthew

                  5301414




                  5301414













                  • Merge will merge your files together into one.

                    – ladle3000
                    Oct 5 '18 at 13:45



















                  • Merge will merge your files together into one.

                    – ladle3000
                    Oct 5 '18 at 13:45

















                  Merge will merge your files together into one.

                  – ladle3000
                  Oct 5 '18 at 13:45





                  Merge will merge your files together into one.

                  – ladle3000
                  Oct 5 '18 at 13:45











                  0














                  Have you tried to flush the JavaScript/CSS? You can do this under System>Cache Management and then press the button which is on the bottom of the table on the left 'Flus JavaScript/CSS Cache'






                  share|improve this answer
























                  • YEP.... flush js, then cache. Nothing change. However, if I switch to Developer mode, the merge works.

                    – BrunoBueno
                    Mar 16 '16 at 17:03
















                  0














                  Have you tried to flush the JavaScript/CSS? You can do this under System>Cache Management and then press the button which is on the bottom of the table on the left 'Flus JavaScript/CSS Cache'






                  share|improve this answer
























                  • YEP.... flush js, then cache. Nothing change. However, if I switch to Developer mode, the merge works.

                    – BrunoBueno
                    Mar 16 '16 at 17:03














                  0












                  0








                  0







                  Have you tried to flush the JavaScript/CSS? You can do this under System>Cache Management and then press the button which is on the bottom of the table on the left 'Flus JavaScript/CSS Cache'






                  share|improve this answer













                  Have you tried to flush the JavaScript/CSS? You can do this under System>Cache Management and then press the button which is on the bottom of the table on the left 'Flus JavaScript/CSS Cache'







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 15 '16 at 23:15









                  Mr. LewisMr. Lewis

                  1,288710




                  1,288710













                  • YEP.... flush js, then cache. Nothing change. However, if I switch to Developer mode, the merge works.

                    – BrunoBueno
                    Mar 16 '16 at 17:03



















                  • YEP.... flush js, then cache. Nothing change. However, if I switch to Developer mode, the merge works.

                    – BrunoBueno
                    Mar 16 '16 at 17:03

















                  YEP.... flush js, then cache. Nothing change. However, if I switch to Developer mode, the merge works.

                  – BrunoBueno
                  Mar 16 '16 at 17:03





                  YEP.... flush js, then cache. Nothing change. However, if I switch to Developer mode, the merge works.

                  – BrunoBueno
                  Mar 16 '16 at 17:03











                  0














                  You need to redeploy static after enabling this option in production mode.






                  share|improve this answer
























                  • The point is, I'm doing it. I just posted here what I did.

                    – BrunoBueno
                    Mar 16 '16 at 17:02













                  • If it not works then problem maybe in in permission. Can you check your webserver access/errors log

                    – KAndy
                    Mar 17 '16 at 14:01
















                  0














                  You need to redeploy static after enabling this option in production mode.






                  share|improve this answer
























                  • The point is, I'm doing it. I just posted here what I did.

                    – BrunoBueno
                    Mar 16 '16 at 17:02













                  • If it not works then problem maybe in in permission. Can you check your webserver access/errors log

                    – KAndy
                    Mar 17 '16 at 14:01














                  0












                  0








                  0







                  You need to redeploy static after enabling this option in production mode.






                  share|improve this answer













                  You need to redeploy static after enabling this option in production mode.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 16 '16 at 5:28









                  KAndyKAndy

                  15.9k23044




                  15.9k23044













                  • The point is, I'm doing it. I just posted here what I did.

                    – BrunoBueno
                    Mar 16 '16 at 17:02













                  • If it not works then problem maybe in in permission. Can you check your webserver access/errors log

                    – KAndy
                    Mar 17 '16 at 14:01



















                  • The point is, I'm doing it. I just posted here what I did.

                    – BrunoBueno
                    Mar 16 '16 at 17:02













                  • If it not works then problem maybe in in permission. Can you check your webserver access/errors log

                    – KAndy
                    Mar 17 '16 at 14:01

















                  The point is, I'm doing it. I just posted here what I did.

                  – BrunoBueno
                  Mar 16 '16 at 17:02







                  The point is, I'm doing it. I just posted here what I did.

                  – BrunoBueno
                  Mar 16 '16 at 17:02















                  If it not works then problem maybe in in permission. Can you check your webserver access/errors log

                  – KAndy
                  Mar 17 '16 at 14:01





                  If it not works then problem maybe in in permission. Can you check your webserver access/errors log

                  – KAndy
                  Mar 17 '16 at 14:01











                  0














                  Make sure you check your NGINX configuration file as well.



                  If there is a variable $MAGE_MODE set there it needs to be changed to production as well, and save the file



                  After that you will need to reload or restart NGINX depending on your preference.



                  sudo service nginx reload


                  OR



                  sudo service nginx restart


                  After that check your app/etc/env.php and see if the MAGE_MODE array key is set to production as well if not change it to production or you can use the command



                  php bin/magento deploy:mode:set production


                  After you executed the command check if the value changed app/etc/env.php, sometimes there might be permission issues.



                  Next, clean out the pub/static folder.



                  rm -rf pub/static/*


                  Clear/Flush your cache



                  php bin/magento cache:clean
                  php bin/magento cache:flush


                  Now you are ready to execute the static content deploy



                  php bin/magento setup:static-content:deploy


                  Hope this helps.






                  share|improve this answer




























                    0














                    Make sure you check your NGINX configuration file as well.



                    If there is a variable $MAGE_MODE set there it needs to be changed to production as well, and save the file



                    After that you will need to reload or restart NGINX depending on your preference.



                    sudo service nginx reload


                    OR



                    sudo service nginx restart


                    After that check your app/etc/env.php and see if the MAGE_MODE array key is set to production as well if not change it to production or you can use the command



                    php bin/magento deploy:mode:set production


                    After you executed the command check if the value changed app/etc/env.php, sometimes there might be permission issues.



                    Next, clean out the pub/static folder.



                    rm -rf pub/static/*


                    Clear/Flush your cache



                    php bin/magento cache:clean
                    php bin/magento cache:flush


                    Now you are ready to execute the static content deploy



                    php bin/magento setup:static-content:deploy


                    Hope this helps.






                    share|improve this answer


























                      0












                      0








                      0







                      Make sure you check your NGINX configuration file as well.



                      If there is a variable $MAGE_MODE set there it needs to be changed to production as well, and save the file



                      After that you will need to reload or restart NGINX depending on your preference.



                      sudo service nginx reload


                      OR



                      sudo service nginx restart


                      After that check your app/etc/env.php and see if the MAGE_MODE array key is set to production as well if not change it to production or you can use the command



                      php bin/magento deploy:mode:set production


                      After you executed the command check if the value changed app/etc/env.php, sometimes there might be permission issues.



                      Next, clean out the pub/static folder.



                      rm -rf pub/static/*


                      Clear/Flush your cache



                      php bin/magento cache:clean
                      php bin/magento cache:flush


                      Now you are ready to execute the static content deploy



                      php bin/magento setup:static-content:deploy


                      Hope this helps.






                      share|improve this answer













                      Make sure you check your NGINX configuration file as well.



                      If there is a variable $MAGE_MODE set there it needs to be changed to production as well, and save the file



                      After that you will need to reload or restart NGINX depending on your preference.



                      sudo service nginx reload


                      OR



                      sudo service nginx restart


                      After that check your app/etc/env.php and see if the MAGE_MODE array key is set to production as well if not change it to production or you can use the command



                      php bin/magento deploy:mode:set production


                      After you executed the command check if the value changed app/etc/env.php, sometimes there might be permission issues.



                      Next, clean out the pub/static folder.



                      rm -rf pub/static/*


                      Clear/Flush your cache



                      php bin/magento cache:clean
                      php bin/magento cache:flush


                      Now you are ready to execute the static content deploy



                      php bin/magento setup:static-content:deploy


                      Hope this helps.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Sep 30 '16 at 5:13









                      Atish GoswamiAtish Goswami

                      3,38931646




                      3,38931646























                          0














                          I just did the following and the problem was solved.



                          bin/magento setup:upgrade

                          bin/magento indexer:reindex

                          bin/magento deploy:mode:set production -s

                          bin/magento setup:di:compile


                          (Here was the secret, to run the di:compile after production)



                          bin/magento setup:static-content:deploy





                          share|improve this answer






























                            0














                            I just did the following and the problem was solved.



                            bin/magento setup:upgrade

                            bin/magento indexer:reindex

                            bin/magento deploy:mode:set production -s

                            bin/magento setup:di:compile


                            (Here was the secret, to run the di:compile after production)



                            bin/magento setup:static-content:deploy





                            share|improve this answer




























                              0












                              0








                              0







                              I just did the following and the problem was solved.



                              bin/magento setup:upgrade

                              bin/magento indexer:reindex

                              bin/magento deploy:mode:set production -s

                              bin/magento setup:di:compile


                              (Here was the secret, to run the di:compile after production)



                              bin/magento setup:static-content:deploy





                              share|improve this answer















                              I just did the following and the problem was solved.



                              bin/magento setup:upgrade

                              bin/magento indexer:reindex

                              bin/magento deploy:mode:set production -s

                              bin/magento setup:di:compile


                              (Here was the secret, to run the di:compile after production)



                              bin/magento setup:static-content:deploy






                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Jul 26 '17 at 7:06









                              Devtype

                              2,18911332




                              2,18911332










                              answered Jul 26 '17 at 6:48







                              user52726






























                                  0
















                                  1. Please also enable "Enable JavaScript Bundling" option



                                    store->configuration->advanced->developer->javascript setting->



                                  2. Enable JavaScript Bundling set to "yes" And flush cache







                                  share|improve this answer





















                                  • 1





                                    Haphazard advice that has nothing to do with the question.

                                    – ladle3000
                                    Oct 5 '18 at 13:46
















                                  0
















                                  1. Please also enable "Enable JavaScript Bundling" option



                                    store->configuration->advanced->developer->javascript setting->



                                  2. Enable JavaScript Bundling set to "yes" And flush cache







                                  share|improve this answer





















                                  • 1





                                    Haphazard advice that has nothing to do with the question.

                                    – ladle3000
                                    Oct 5 '18 at 13:46














                                  0












                                  0








                                  0









                                  1. Please also enable "Enable JavaScript Bundling" option



                                    store->configuration->advanced->developer->javascript setting->



                                  2. Enable JavaScript Bundling set to "yes" And flush cache







                                  share|improve this answer

















                                  1. Please also enable "Enable JavaScript Bundling" option



                                    store->configuration->advanced->developer->javascript setting->



                                  2. Enable JavaScript Bundling set to "yes" And flush cache








                                  share|improve this answer














                                  share|improve this answer



                                  share|improve this answer








                                  edited Jul 26 '17 at 7:17









                                  Teja Bhagavan Kollepara

                                  2,98641947




                                  2,98641947










                                  answered Sep 30 '16 at 4:56









                                  Sagar DobariyaSagar Dobariya

                                  1,0501827




                                  1,0501827








                                  • 1





                                    Haphazard advice that has nothing to do with the question.

                                    – ladle3000
                                    Oct 5 '18 at 13:46














                                  • 1





                                    Haphazard advice that has nothing to do with the question.

                                    – ladle3000
                                    Oct 5 '18 at 13:46








                                  1




                                  1





                                  Haphazard advice that has nothing to do with the question.

                                  – ladle3000
                                  Oct 5 '18 at 13:46





                                  Haphazard advice that has nothing to do with the question.

                                  – ladle3000
                                  Oct 5 '18 at 13:46











                                  0














                                  I've had the problem when the JavaScript is un-compiled the jquery selector works.




                                  $('#my_element').click(function(){ alert('Hello World');});


                                  But once compiled, compressed and joined, I then need to code:-




                                  $('body #my_element').click(function(){ alert('Hello World');});


                                  Don't ask why, it seems that when reading directly from the cache, the requirejs code executes before the domReady and the elements attach to different elements in some different page.






                                  share|improve this answer




























                                    0














                                    I've had the problem when the JavaScript is un-compiled the jquery selector works.




                                    $('#my_element').click(function(){ alert('Hello World');});


                                    But once compiled, compressed and joined, I then need to code:-




                                    $('body #my_element').click(function(){ alert('Hello World');});


                                    Don't ask why, it seems that when reading directly from the cache, the requirejs code executes before the domReady and the elements attach to different elements in some different page.






                                    share|improve this answer


























                                      0












                                      0








                                      0







                                      I've had the problem when the JavaScript is un-compiled the jquery selector works.




                                      $('#my_element').click(function(){ alert('Hello World');});


                                      But once compiled, compressed and joined, I then need to code:-




                                      $('body #my_element').click(function(){ alert('Hello World');});


                                      Don't ask why, it seems that when reading directly from the cache, the requirejs code executes before the domReady and the elements attach to different elements in some different page.






                                      share|improve this answer













                                      I've had the problem when the JavaScript is un-compiled the jquery selector works.




                                      $('#my_element').click(function(){ alert('Hello World');});


                                      But once compiled, compressed and joined, I then need to code:-




                                      $('body #my_element').click(function(){ alert('Hello World');});


                                      Don't ask why, it seems that when reading directly from the cache, the requirejs code executes before the domReady and the elements attach to different elements in some different page.







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Jan 14 '18 at 2:51









                                      Dallas ClarkeDallas Clarke

                                      73779




                                      73779























                                          -1














                                          Delete cache manually var/cache and delete session manually var/session






                                          share|improve this answer



















                                          • 1





                                            Deleting var/session is never an appropiate solution. magento.stackexchange.com/questions/94589/…

                                            – Fabian Schmengler
                                            Sep 14 '16 at 10:42
















                                          -1














                                          Delete cache manually var/cache and delete session manually var/session






                                          share|improve this answer



















                                          • 1





                                            Deleting var/session is never an appropiate solution. magento.stackexchange.com/questions/94589/…

                                            – Fabian Schmengler
                                            Sep 14 '16 at 10:42














                                          -1












                                          -1








                                          -1







                                          Delete cache manually var/cache and delete session manually var/session






                                          share|improve this answer













                                          Delete cache manually var/cache and delete session manually var/session







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered Mar 16 '16 at 18:05









                                          Usman FayyazUsman Fayyaz

                                          10412




                                          10412








                                          • 1





                                            Deleting var/session is never an appropiate solution. magento.stackexchange.com/questions/94589/…

                                            – Fabian Schmengler
                                            Sep 14 '16 at 10:42














                                          • 1





                                            Deleting var/session is never an appropiate solution. magento.stackexchange.com/questions/94589/…

                                            – Fabian Schmengler
                                            Sep 14 '16 at 10:42








                                          1




                                          1





                                          Deleting var/session is never an appropiate solution. magento.stackexchange.com/questions/94589/…

                                          – Fabian Schmengler
                                          Sep 14 '16 at 10:42





                                          Deleting var/session is never an appropiate solution. magento.stackexchange.com/questions/94589/…

                                          – Fabian Schmengler
                                          Sep 14 '16 at 10:42


















                                          draft saved

                                          draft discarded




















































                                          Thanks for contributing an answer to Magento Stack Exchange!


                                          • Please be sure to answer the question. Provide details and share your research!

                                          But avoid



                                          • Asking for help, clarification, or responding to other answers.

                                          • Making statements based on opinion; back them up with references or personal experience.


                                          To learn more, see our tips on writing great answers.




                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f106436%2fmerged-js-and-css-do-not-work-when-production-mode%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          Alcázar de San Juan

                                          Griza ansero

                                          Heinkel He 51