# Why the OpenMage CSS/JS Minify Module Recommends Disabling Native Magento Merging (Especially with HTTP/2)

> Learn why OpenMage CSS/JS Minify module suggests disabling native Magento merging. Improve caching and performance with HTTP/2 efficiency.

- Repository: [Fabrizio Balliano/openmage-cssjs-minify](https://github.com/fballiano/openmage-cssjs-minify)
- Tags: best-practices
- Published: 2026-03-01

---

**Disable Magento’s native CSS/JS merging when using the OpenMage CSS/JS Minify module to allow per-file minification and hash-based caching, which HTTP/2 multiplexing makes more efficient than monolithic bundles.**

The `fballiano/openmage-cssjs-minify` module enhances OpenMage (and Magento 1) performance by intercepting the HTML response and swapping asset URLs with minified versions. However, the module’s README explicitly warns against using Magento’s built-in merging feature, calling it an "old relic of the M1 era" that becomes unnecessary with HTTP/2. This recommendation stems from fundamental conflicts between how the core merging logic and the module’s observer-based minification interact.

## How the Minification Module Intercepts Assets

The module registers an observer on the `http_response_send_before` event in [`app/code/community/Fballiano/CssjsMinify/etc/config.xml`](https://github.com/fballiano/openmage-cssjs-minify/blob/main/app/code/community/Fballiano/CssjsMinify/etc/config.xml). This allows the [`Observer.php`](https://github.com/fballiano/openmage-cssjs-minify/blob/main/Observer.php) class to inspect the final HTML body before it reaches the browser.

Inside [`app/code/community/Fballiano/CssjsMinify/Model/Observer.php`](https://github.com/fballiano/openmage-cssjs-minify/blob/main/app/code/community/Fballiano/CssjsMinify/Model/Observer.php), the module uses regex patterns to locate every `<script>` and `<link>` tag referencing CSS or JS files:

```php
// Pattern matching for JavaScript files
$pattern = '/(<script.+src\s*=\s*["\'])(.*\.js)(["\'].*>)/iU';

```

For each match, the module:
1. Generates a content hash based on the original file path and modification time
2. Creates a minified copy under `media/fbminify/` using the `matthiasmullie/minify` library
3. Replaces the original URL in the HTML with the new minified path (e.g., [`media/fbminify/9a7b3c1d2e-1638427200.js`](https://github.com/fballiano/openmage-cssjs-minify/blob/main/media/fbminify/9a7b3c1d2e-1638427200.js))

## Why Native Magento Merging Breaks the Workflow

When Magento’s native merging is enabled (System → Configuration → Developer → JavaScript Settings → Merge JavaScript Files), the core system concatenates all individual assets into a single combined file **before** the `http_response_send_before` event fires.

This creates three critical problems for the minification module:

1. **No tags to replace**: The HTML contains only one `<script>` tag for the merged bundle instead of individual tags for each asset. The regex in [`Observer.php`](https://github.com/fballiano/openmage-cssjs-minify/blob/main/Observer.php) finds only this single merged file, leaving the majority of assets unprocessed by the minifier.

2. **Loss of advanced minification**: The merged file bypasses the `MatthiasMullie\Minify` library entirely. Magento’s built-in minifier (if enabled) uses older, less efficient algorithms compared to the modern minification provided by this module.

3. **Cache invalidation inefficiency**: Native merging generates a single cache key for the entire bundle. When **any** constituent file changes, the entire merged file must be regenerated and redownloaded by all clients. In contrast, the module’s per-file hashing means only changed files get new URLs, allowing browsers to retain cached copies of unchanged assets.

## The HTTP/2 Factor: Why Merging Is Obsolete

The module’s README explicitly states that native merging is "not necessary anymore since HTTP/2." This recommendation reflects modern web protocol capabilities that eliminate the original performance justification for file concatenation.

**HTTP/2 multiplexing** allows multiple simultaneous requests over a single TCP connection. Unlike HTTP/1.1, which required expensive handshakes for each asset, HTTP/2 can download dozens of small files concurrently without blocking. This eliminates the "reduce HTTP requests" rationale that made merging attractive in the Magento 1 era.

By disabling merging and using the minification module, you gain:

* **Granular caching**: Each minified file receives a unique hash based on content (e.g., `md5($path)-$time.js`), allowing browsers to cache individual assets indefinitely and only re-download modified files.

* **Superior compression**: The `matthiasmullie/minify` library typically achieves better compression ratios than Magento’s legacy minifier, especially for modern JavaScript syntax.

* **Efficient cache cleanup**: The module’s `dailyCron` task scans `media/fbminify/` and removes duplicate hashes, which works naturally when assets are stored as individual files rather than monolithic bundles.

As noted in the README:

> "Make sure that CSS/JS merging (the one provided by OpenMage core) is disabled (it's an old relic of the M1 era and it's not necessary anymore since HTTP2)."

## Configuration: Disabling Native Merging

To implement the recommended configuration, disable Magento’s built-in merging via the admin panel or programmatically.

**Via Admin Panel:**

Navigate to:

```

System → Configuration → Developer → JavaScript Settings → Merge JavaScript Files = No
System → Configuration → Developer → CSS Settings → Merge CSS Files = No

```

**Via [`app/etc/local.xml`](https://github.com/fballiano/openmage-cssjs-minify/blob/main/app/etc/local.xml):**

```xml
<default>
    <dev>
        <js>
            <merge>0</merge>
        </js>
        <css>
            <merge>0</merge>
        </css>
    </dev>
</default>

```

**Enable HTTP/2 (Apache example):**

```apache

# Requires Apache 2.4+ with mod_http2 loaded

Protocols h2 h2c http/1.1

```

Once configured, the module will rewrite requests like [`skin/frontend/theme/js/app.js`](https://github.com/fballiano/openmage-cssjs-minify/blob/main/skin/frontend/theme/js/app.js) to [`media/fbminify/9a7b3c1d2e-1638427200.js`](https://github.com/fballiano/openmage-cssjs-minify/blob/main/media/fbminify/9a7b3c1d2e-1638427200.js), allowing each asset to be cached and served independently over HTTP/2.

## Summary

* **Disable native merging** when using `fballiano/openmage-cssjs-minify` to allow the module’s `http_response_send_before` observer to intercept and minify individual asset tags.
* Native merging concatenates files before the observer runs, preventing per-file minification and forcing inefficient full-bundle cache invalidation.
* HTTP/2 multiplexing eliminates the performance benefit of reducing request counts, making granular, minified files more efficient than monolithic bundles.
* The module stores minified assets in `media/fbminify/` with content-based hashes, enabling precise browser caching and efficient cleanup via the `dailyCron` task.

## Frequently Asked Questions

### What happens if I leave Magento's native merging enabled?

If native merging remains active, OpenMage combines all CSS or JS files into a single bundle before the `http_response_send_before` event fires. The minification module’s regex in [`Observer.php`](https://github.com/fballiano/openmage-cssjs-minify/blob/main/Observer.php) finds only one merged tag instead of individual assets, meaning most files bypass the `matthiasmullie/minify` library entirely. You lose per-file hashing and force clients to re-download the entire bundle when any single asset changes.

### Does HTTP/2 completely eliminate the need for file merging?

For modern OpenMage deployments, yes. HTTP/2’s multiplexing capability allows dozens of simultaneous requests over a single TCP connection without the head-of-line blocking that plagued HTTP/1.1. Since the protocol handles many small files efficiently, the primary historical benefit of merging—reducing HTTP request overhead—no longer applies. Disabling merging allows the minification module to serve granular, optimally cached assets instead of monolithic bundles.

### How does the hash-based caching work in this module?

When the [`Observer.php`](https://github.com/fballiano/openmage-cssjs-minify/blob/main/Observer.php) processes an asset, it generates a unique filename using `md5($path)` combined with the file modification time (e.g., [`9a7b3c1d2e-1638427200.js`](https://github.com/fballiano/openmage-cssjs-minify/blob/main/9a7b3c1d2e-1638427200.js)). This hash is stored in `media/fbminify/`. Because the URL changes only when the source file content changes, browsers can cache the asset indefinitely. The module’s `dailyCron` task periodically scans this directory to remove outdated duplicate hashes, keeping the cache clean without manual intervention.

### Can I use this module with standard Magento 1 instead of OpenMage?

Yes, the module is compatible with standard Magento 1 installations, though it is specifically maintained for OpenMage. The logic in [`app/code/community/Fballiano/CssjsMinify/Model/Observer.php`](https://github.com/fballiano/openmage-cssjs-minify/blob/main/app/code/community/Fballiano/CssjsMinify/Model/Observer.php) and the event observer in [`config.xml`](https://github.com/fballiano/openmage-cssjs-minify/blob/main/config.xml) rely on standard Magento 1 events like `http_response_send_before`, which are present in both platforms. However, OpenMage users benefit from continued security patches and PHP 8 compatibility that ensure the minification library operates correctly under modern server environments.