Hello, My name is Cuong, I’m a Magento Developer, Welcome back to my Magento 2 tutorial video series.
#magento2tutorial #magento2training #magento2
We can check this on the storefront.
I have 148 JS files and 5 CSS files on the homepage.
I have 172 JS files and 6 CSS files on the product detail page.
I have 158 JS files and 6 CSS files on the catalog category detail page.
So if a user visits my website, they need to send a huge amount of requests from 154 to 180 to my server to load the content of these files. If I merge these files into one single file, so a user only sends 2 requests to my server. One for the JS file and One for the CSS file.
By default, Magento 2 provides us with a feature, that allows us to merge the JS and CSS files into one single file in the configuration.
Let’s enable this feature in Magento 2 you can follow some simple steps which are given below:
Step 1: Set the Magento mode
– To enable this feature, you need to set the Magento mode to the “developer”
– Open the file named env.php for editing in the path appetc
– Change the MAGE_MODE to the “developer”, then save the file.
– Go to the Magento Admin Panel and navigate to the Stores → Settings → Configuration → Advanced → Developer
– Open the CSS Settings tab. Select the Merge CSS Files as “Yes”.
– Click the Save Config button.
Step 3: Set the Magento mode to production
– Run the following command line:
php bin/magento deploy:mode:set production
This process will take much time, it depends on your server speed. Wait for 10 minutes.
Step 4: Test and see the results
Go to the storefront.
Yeah, It works perfectly.
Thanks for watching the guide. If you have any questions about this practice, please feel free to leave a comment below.
Don’t forget to like, comment, share my videos and subscribe to my channel for getting the latest lessons.
Please do not hesitate to contact me, if you need me to join your Magento project. My rate is $25/hour in Magento 1 and $30/hour in Magento 2.