Skip to Content

Performance

When your store is ready to sell, do not forget properly configure Magento and enable production mode.

Here is a one-line command that will set configuration 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 😉.