# How to enable JavaScript / CSS merging and minifying in Magento 2

> Enable JavaScript and CSS merging and minifying in Magento 2 to reduce page load times and improve your store's performance.

Source: https://www.kualo.com/knowledgebase/magento-performance/how-to-enable-javascript-css-merging-minifying-in-magento-v2
Updated: 2026-06-13

---

Enabling JavaScript and CSS merging and minifying in Magento 2 reduces the number of files your visitors download and the number of connections made to your server, resulting in a faster, more responsive store.

![How to enable Javascript CSS Merging & Minifying in Magento v2](https://kb-cdn.kualo.com/94/ec/94ecfe0b8e03c4a92e4e2361a59bc40fc47507c8.jpg)

## Enable JavaScript merging and minifying

1. Log in to your Magento Admin Dashboard.
2. Go to **Stores > Settings > Configuration**.
3. In the left-hand menu, select **Advanced > Developer**.
4. Expand the **JavaScript Settings** section.
5. Set the following options to **Yes**:
   - Merge JavaScript Files
   - Enable JavaScript Bundling
   - Minify JavaScript Files
6. Click **Save Config**.

![JavaScript settings in Magento 2 Admin](https://kb-cdn.kualo.com/14/34/1434d85bba2e89e3d15e9d430a23f704bacfc380.png)

:::warning
There are reports that Magento's built-in merge and minify features can occasionally slow down certain stores. Test your site's performance after enabling these settings and disable any option that has a negative effect.
:::

## Enable CSS merging and minifying

1. On the same **Advanced > Developer** configuration page, expand the **CSS Settings** section.
2. Set the following options to **Yes**:
   - Merge CSS Files
   - Minify CSS Files
3. Click **Save Config**.

![CSS settings in Magento 2 Admin](https://kb-cdn.kualo.com/82/7f/827f9572d0a534415505e4f6cd702bb4aab3e20b.png)

## Flush the cache

After saving, Magento will prompt you to clear the cache. Click **Cache Management** in the notification bar and flush the cache to apply your changes.

## Further optimisation with Cloudflare

As an alternative - or complement - to Magento's built-in tools, you can use Cloudflare to handle minification of JS, CSS, and HTML. This can be particularly useful if Magento's own merging causes issues on your store.

![Cloudflare auto-minify settings](https://kb-cdn.kualo.com/7a/96/7a96ec15ac1236f50863a602b77a85060d1c82aa.png)

A common approach is to use Magento for merging and bundling, and let Cloudflare handle minification. Kualo is a Cloudflare optimised partner, so your site can also benefit from Cloudflare's CDN and Rocket Loader features.

## Before and after comparison

The screenshots below show the difference in page load performance between a default Magento 2 store and one with merging and minifying enabled.

**Before:**

[![Before - default Magento store](https://kb-cdn.kualo.com/3f/ea/3feab4d653d664b68701abf3e77ca7dbd15055a4.png)](https://screens.kgix.net/tt/Before.png)

**After:**

[![After - merged and minified](https://kb-cdn.kualo.com/ae/5b/ae5bdb316a78ffd29f8160ee8c5701f1a558c2c8.png)](https://screens.kgix.net/tt/After.png)

![Performance comparison detail](https://kb-cdn.kualo.com/cb/d6/cbd6e396a643bc2ac17d8a66ac76eb4107a653b8.png)

If you need any help with this, please [contact us](https://www.kualo.com/company/contact).

---

_Source: Kualo Knowledgebase — https://www.kualo.com/knowledgebase/magento-performance/how-to-enable-javascript-css-merging-minifying-in-magento-v2 · © Kualo Ltd._
