3

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 Oct 14 '16 at 9:52
  • Hi @Pradeep Kumar did you get any solution? Facing same issue in Magento 2.1.2 CE Version – Ankit Shah Nov 23 '16 at 5:22
  • @AnkitShah :- check my latest answer – Pradeep Kumar Nov 23 '16 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 Mar 17 '17 at 15:07
1

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

0

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.

0

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

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.