Performance
The table below shows the options that will improve store performance and their recommended values:
Option | Default Value | Recommended Value |
---|---|---|
Minify Html | No | Yes |
Merge JavaScript Files | No | Yes |
Enable JavaScript Bundling | No | No |
Minify JavaScript Files | No | Yes |
Merge CSS Files | No | Yes |
Minify CSS Files | No | Yes |
Use CSS critical path | No | Yes |
Here is a one-line command that will set all of these settings to the recommended values:
bin/magento config:set dev/template/minify_html 1 &&\
bin/magento config:set dev/js/merge_files 1 &&\
bin/magento config:set dev/js/enable_js_bundling 0 &&\
bin/magento config:set dev/js/minify_files 1 &&\
bin/magento config:set dev/css/merge_css_files 1 &&\
bin/magento config:set dev/css/minify_files 1 &&\
bin/magento config:set dev/css/use_css_critical_path 1
The next command will switch your store to the production mode:
bin/magento maintenance:enable &&\
bin/magento cache:clean &&\
rm -rf generated/code &&\
rm -rf generated/metadata &&\
rm -rf var/view_preprocessed/pub/static/frontend/ &&\
rm -rf pub/static/frontend/ &&\
bin/magento deploy:mode:set production --skip-compilation &&\
bin/magento setup:di:compile &&\
bin/magento setup:static-content:deploy &&\
bin/magento maintenance:disable
That’s all. It’s also recommended to run a crawler (Cache Warmer) afterward to warm up Magento’s cache.
You can then check your score at Google PageSpeed Insights and share your result with us on Twitter 😉.