Magento2: Merge CSS Files causes entire site to load Extremely Slow

Created on 27 Apr 2016  路  36Comments  路  Source: magento/magento2

Steps to reproduce

  1. Install Magento 2.0.4
  2. Go to Admin > Stores > Configuration > Advanced > Developer
  3. Enable "Merge CSS files"

    Expected result

  4. CSS files will be merged and site will load faster.

    Actual result

  5. Entire site runs EXTREMELY SLOW.

  6. Both frontend and backend take 15-45 secs to load each page (cached). Product pages, checkout pages, admin pages are all affected.
  7. Tried redeploying static files and flushing cache, does not help.
  8. As soon as setting is disabled, site returns to normal.
Frontend Fixed in 2.2.x Format is not valid Ready for Work bug report

All 36 comments

Renderer::renderAssetHtml($template, $assets)

// load much time
foreach ($assets as $asset)

$assets may not be array, so need to force the variable to array,

Same problem here.

Same issue here

same issue works better without merging css / js

Please, provide the used version. If the problem is actual for a specific branch, please, specify it and be sure that the latest update was used.

@wert2all At least with 2.0.7. When "Merge CSS" is activated, the system become very slow.

Same issue here on 2.0.7

Same issue on 2.1
Anyone?

@LucScu my issue was solved when I upgraded to 2.1.

Did you test this issue on a new 2.1 installation?

I upgraded from 2.0.7 to 2.1 and issue still continue.
Have i to do something to make it works?

Same issue on 2.1.1

why none ufficial magento developer reply here?

tested now with 2.1 and all works correctly, maybe there were some issues with theme (porto) or my customizations.

Not working on my side on a fresh install of Magento 2.1.1 in developer mode.

It not works on dev mode! Only production, it is written on admin.

@acharrex @LucScu we'll look into the issue asap. Thank you for your patience
MAGETWO-59053

@tkacheva I think it is not an issue, in production mode it works correctly.

I'm on the latest 2.1.1 in production mode and enabling Merge Css makes the whole site crawl. I also have the Porto theme so maybe its related to the issue.

@cowmix88 do you set both nginx and magento to production mode? All things work good on my 2.1

I have Magento is set to production mode through command line and no mode settings in nginx. Do I need to set the mode in nginx as well?

Pages take less than a second to load normally, as soon as I enable the merge css setting in config it jumps to 5+ seconds, turn it off again and pages return to taking less than a second.

I discovered my issue was actually caused by invalid permissions on the static folder, it works correctly now.

@cowmix88 yes, you have to set nginx in production mode.

I tested on 2.1.2.
When Magento is in developer mode, I enable Merge Css, then the whole site crawl.
But When I switch to production mode first, then enable Merge CSS, it's ok.

Thank you @LucScu your suggestion worked for me. Production mode was set in Magento but not in Nginx. Not it's working perfectly.

Same with M2.1.0 CE, developer mode works fine with merge_css_files = 1, but production mode slows down to 20+secs each page load

I've got the same issue that the store is getting very slow with merged/minified css on 2.1.2 and with porto theme. It applies to both developer and production mode.

Same here on 2.1.3

I am also witnessing this on Enterprise 2.1.3.
Only happens when in "developer" mode and merge_css_files is set to 1 in config.

I have also the same problem on Magento CE 2.1 in production mode running on Apache2.
When merge_css_files is set to 1, I can see stuff like this in the logs:

access("/var/www/html/app/design/frontend/Codazon/fastest/drug_pharmacy/Codazon_MegaMenu/web/i18n/fr_FR/css/font-awesome/font-awesome.min.css", F_OK) = -1 ENOENT (No such file or directory)
access("/var/www/html/app/design/frontend/Codazon/fastest/drug_pharmacy/Codazon_MegaMenu/web/css/font-awesome/font-awesome.min.css", F_OK) = -1 ENOENT (No such file or directory)
access("/var/www/html/app/design/frontend/Codazon/fastest/fashion/Codazon_MegaMenu/web/i18n/fr_FR/css/font-awesome/font-awesome.min.css", F_OK) = -1 ENOENT (No such file or directory)
access("/var/www/html/app/design/frontend/Codazon/fastest/fashion/Codazon_MegaMenu/web/css/font-awesome/font-awesome.min.css", F_OK) = -1 ENOENT (No such file or directory)
access("/var/www/html/vendor/magento/theme-frontend-blank/Codazon_MegaMenu/web/i18n/fr_FR/css/font-awesome/font-awesome.min.css", F_OK) = -1 ENOENT (No such file or directory)
access("/var/www/html/vendor/magento/theme-frontend-blank/Codazon_MegaMenu/web/css/font-awesome/font-awesome.min.css", F_OK) = -1 ENOENT (No such file or directory)
access("/var/www/html/app/code/Codazon/MegaMenu/view/frontend/web/i18n/fr_FR/css/font-awesome/font-awesome.min.css", F_OK) = -1 ENOENT (No such file or directory)
access("/var/www/html/app/code/Codazon/MegaMenu/view/base/web/i18n/fr_FR/css/font-awesome/font-awesome.min.css", F_OK) = -1 ENOENT (No such file or directory)

I have tried to deploy again static files for my template (as my files collection should be different) but it doesn't change anything.

Has someone tried to use Luna as theme to see if this is not a theme issue?

Also in the logs:
stat("/var/www/html/vendor/magento/module-send-friend/view/frontend/web/css/source/_module.less", 0x7ffcb080caa0) = -1 ENOENT (No such file or directory)
stat("/var/www/html/vendor/magento/module-sample-data/view/frontend/web/css/source/_module.less", 0x7ffcb080caa0) = -1 ENOENT (No such file or directory)
stat("/var/www/html/vendor/magento/module-product-video/view/frontend/web/css/source/_module.less", 0x7ffcb080caa0) = -1 ENOENT (No such file or directory)

So, it's not only theming problem.

I think this issue just happen in developer mode... Have to test it

I got this happening on following:

  • Magento 2.1.5
  • Mode: Production
  • PHP 7.0.22

Merging JS does not trigger the same issue.

Any update? i still have issue with merged css while js merging is working fine.

@stevekem thank you for your report.
The fix for this issue is already fixed in 2.2.0 release

I'm running magento 2.2.2 and porto 3.0.4. I enabled merge css and the site is really slow. I tried switching to production mode but this didn't help. And now i can't get back to default mode to disable it. Now i try to get in developer mode but this gives me the following error: The directory "/home/xxxxx/domains/xxxxx/public_html/pub/static/frontend" cannot be deleted Warning!rmdir(/home/xxx/domains/xxxx/public_html/pub/static/frontend): Directory not empty. I can change the permission of this folder but i don't think i want anything deleted from this folder right?
Also i'm only trying to access developer mode to change the css minify. But i'm hoping somebody got a fix :)

Was this page helpful?
0 / 5 - 0 ratings