Articles on: Magento 2 User Guide

How to minify, merge, bundle of HTML / CSS / JS - Magento Cloud vs. Magento Admin

Magento offers a few ways to control minification, merging, and bundling for HTML, CSS, and JavaScript. The approach differs between Magento Commerce Cloud and a standard install configured via the Magento Admin.



1) Configure HTML/CSS/JS on Magento Commerce Cloud (ECE/B2B)


On Cloud, these settings are committed as configuration rather than toggled only in the Admin.


Step 1 — Export environment configuration

From the root of your Magento ECE project (over SSH):


php vendor/bin/m2-ece-scd-dump


This exports environment config to app/etc/config.php.


Need more details? See Magento Cloud docs on exporting store settings.


Step 2 — Edit app/etc/config.php

Add or adjust the relevant dev keys. Use 1 to enable and 0 to disable.


Note on JS merge: If you enable merge_files for JS, also enable JS bundling or the files won’t merge into a single bundle.


'dev' =>
array (
'static' =>
array (
'sign' => '1',
),
'front_end_development_workflow' =>
array (
'type' => 'server_side_compilation',
),
'template' =>
array (
'minify_html' => '0',
),
'js' =>
array (
'merge_files' => '1',
'minify_files' => '1',
'enable_js_bundling' => '1',
'minify_exclude' => '/tiny_mce/',
'session_storage_logging' => '0',
'translate_strategy' => 'dictionary',
),
'css' =>
array (
'minify_files' => '1',
'merge_css_files' => '1',
'minify_exclude' => '/tiny_mce/',
),
),


magento-cloud-config-php-example.png


Step 3 — Commit, push, and redeploy

After committing to your Cloud Git repo, clear caches and redeploy static content:


php bin/magento cache:clean
php bin/magento cache:flush
rm -Rf var/cache/ var/generation/ var/page_cache/ var/view_preprocessed/
php bin/magento setup:static-content:deploy -f


Performance tip: Always test. Bundling can reduce requests, but on HTTP/2 it may increase Start Render and DOM Content Loaded times.


Test here: https://www.webpagetest.org


webpagetest-results-cloud.png



2) Configure HTML/CSS/JS from Magento Admin (Developer Mode)

These options are visible in Developer mode:


Path: Stores -> Configuration -> Advanced -> Developer -> CSS Settings / JavaScript Settings


magento-admin-developer-css-js-settings.png


After saving, clear caches and redeploy static content:


php bin/magento cache:clean
php bin/magento cache:flush
rm -Rf var/cache/ var/generation/ var/page_cache/ var/view_preprocessed/
php bin/magento setup:static-content:deploy -f


Again, validate with a speed test and watch render timings:


webpagetest-results-admin.png



Quick guidance

  • Cloud: Set values in app/etc/config.php, commit, and deploy.
  • Standard installs: Toggle in Admin (Developer mode), then deploy static content.
  • HTTP/2 note: Prefer minification over heavy bundling; bundle only if real-world tests show improvements.

Updated on: 18/09/2025

Was this article helpful?

Share your feedback

Cancel

Thank you!