Merge + Minify + Refresh


This plugin merges/concatenates Cascading Style Sheets & Javascript files into groups. It then minifies the generated files using Minify (for CSS) and Google Closure (for JS – fallback to Minify when not available). Minification is done via WP-Cron so that it doesn’t slow down the website. When JS or CSS changes files are re-processed. No need to empty cache!

Inspired by MinQueue and Dependency Minification plugins.

Minification by Minify and Google Closure

In order to ensure fast loading times it’s recommended to set long expiry dates for CSS and JS as well as make sure gzip or deflate is on.

Version 1.10 added should_mmr filter which allows developers to disable MMR when needed. You could use this to disable MMR for certain WordPress roles or with some Page Builders. Three new plugins have been created that utilise this:
Merge + Minify + Refresh Check DIVI, Merge + Minify + Refresh Check Visual Composer and Merge + Minify + Refresh Check Beaver Builder. Please install these when required.

Version 1.6 added support for HTTP2 Server Push to further speed up your requests (thanks to Daniel Aleksandersen).

Version 1.6.9 added the ability to specify the cache directory. Set MMR_CACHE_DIR & MMR_CACHE_URL constants in wp-config.php. MMR_CACHE_DIR must be full server path and MMR_CACHE_URL must be absolute URL for this to work correctly (thanks to Daniel Aleksandersen).

Version 1.6.11 added the ability to specify seperate cache urls for javascript and CSS. Use MMR_JS_CACHE_URL & MMR_CSS_CACHE_URL to replace MMR_CACHE_URL.

Version 1.7.0 added the ability to generate .css.gz & .js.gz files. Your webserver may need to be configured to use these files. Here is how to use these files in Apache (mod_rewrite, mod_deflate and mod_headers need to be enabled):

<IfModule mod_rewrite.c>
    <IfModule mod_deflate.c>
        <IfModule mod_headers.c>
#Serve gzip compressed CSS files if they exist and the client accepts gzip.
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}\.gz -s
RewriteRule ^(.*)\.css $1\.css\.gz [QSA]

#Serve gzip compressed JS files if they exist and the client accepts gzip.
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}\.gz -s
RewriteRule ^(.*)\.js $1\.js\.gz [QSA]

#Serve correct content types, and prevent mod_deflate double gzip.
RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1,E=is_gzip:1]
RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1,E=is_gzip:1]
Header set Content-Encoding "gzip" env=is_gzip

Version 1.8.8 added a „merge_minify_refresh_done“ hook that fires when JS or CSS has changed.

Version 1.11 added two new constants:
MMR_USE_CLOSURE – allows Google Closure Javascript minification to be disabled.
MMR_REMOVE_EXPIRED – disables removing expired files.

Version 1.13 added two new filters which can be used to exclude specific files:
Version 1.13 also automatically moves the WordPress inline styles to a global stylesheet which it then enqueues.

Version 1.14.3 added two new filters which can be used to modify the output before it gets saved:

Note Installing this plugin on a server with the eAccellerator module installed has the potential to break as Minify uses anonymous functions which return NULL. View eAccellerator Issue Thread


  • Merges JS and CSS files to reduce the number of HTTP requests
  • Handles scripts loaded in the header & footer
  • Compatible with localised scripts
  • Creates WP-Cron for minification as this can take some time to complete
  • Minifies JS with Google Closure (requires php exec) with fallback to Minify
  • Minifies CSS with Minify
  • Failed minification doesn’t break the site. Visitors will instead only see the merged results
  • Stores Assets in /wp-content/mmr/ folder
  • Uses last modified date in filename so any changes to JS or CSS automatically get re-processed and downloaded on browser refresh
  • View status of merge and minify on settings page in WordPress admin
  • Option to enable http2 server push (thanks to Daniel Aleksandersen)
  • Option to enable output buffering for compatibility and so footer scripts can be HTTP2 pushed
  • Ability to turn off minification
  • Ability to turn off concatenation
  • Ability to manually ignore scripts or css
  • Ignores conditional scripts and styles
  • Ability to specify cache directories
  • Ability to generate .css.gz & .js.gz files (Thanks to Marcus Svensson)
  • Works with WordPress Multisite


  1. Upload the merge-minify-refresh folder to the /wp-content/plugins/ directory or upload the zip within WordPress
  2. Activate the plugin through the ‘Plugins’ menu in WordPress


8. April 2023. 1 reply
I used a website speed test to look at the differences before and after installing this plugin. Of course I waited a while for the merging and minifying to take effect i.e. I visited my website and moved from page to page. The plugin got the number of requests down by 20. What about speed? Well the load time does vary. Even without the plugin, sometimes the website responded a bit faster. It looks like this plugin has reduced the load time for my website by 0.8 seconds. To get this reduction in load time, I had to turn on „enable output buffering“ and both „enable preload“ options. Without these options turned on the speed increase was about 0.4 or 0.5 seconds. This an excellent result. Thanks very much. Now http2 is supposed to make merging have less effect. Is this really true? Is this still the case? Are all the effects from minifying or are they from merging as well?
31. August 2022. 5 replies
It seems to me that: * if the CSS files has @includes it will not work. The option to skip CSS seems to be ignored * If the site is password protected (htpasswd protected site) the minifying part will be skipped.
4. Juni 2022. 1 reply
I discovered that autoptimize generated unwanted 302 redirections. There was a reason for it. autoptimize generates new CSS and JS filenames from time to time. So, then googlebot is lost and autoptimize creates a 302 redirect from old to newly generated CSS and JS files. If you disable their Merge, minify is much better. it uses variables in the URL to show new versions of files. For your information this is the Wordpress approach. It is the best because, Googlebot understands it and it does not create a 404 or a 302 when a CSS file or a JS file is refreshed. To my knowledge this plugin is the only one with this approach. It is super simple. The developer of this plugin didn’t add useless features. i like it. You just install and it is ready out of the box. We don’t need other features. We need this plugin to remain efficient with new versions and to remain the best as it is now. I can see that in the background, this plugin does a great job. It reduces the number of files to the minimum and it is really lightweight. By far, this plugin is the best Merge, minify wordpress plugin
30. Maj 2021. 1 reply
Combines, but doesn’t properly minify .js and fails on dynamic parts of Woocommerce checkout page – vanilla theme – both .js and css.
Read all 68 reviews

Contributors & Developers

“Merge + Minify + Refresh” is open source software. The following people have contributed to this plugin.




  • Only remove css and js url vars for files generated by MMR


  • Change the way non UTF-8 files are detected for better support
  • Fix depreciated encoding warning


  • Add logging when generating gzip files


  • Changed gzip to not require exec
  • fixed gzip not working when minification is disabled


  • Fix blank files being generated sometimes


  • Fixed minify error when gzip enabled


  • MMR now supports script defer/async


  • Fixed css files not being merged


  • Fixed merged files that don’t have a trailing semicolon causing syntax errors
  • Fix syntax error caused by media being a boolean


  • Updated Closure
  • Updated PHP Minify
  • Completely changed the way files are merged. Instead of merging all of the files and then minifying the entire merged file, it now minifys all of the files separatly before merging them. This allows the plugin to use the pre-minified versions of files, saving initial bandwidth on updates and processing time.
  • Changed default behaviour to splitting on inline scripts and styles. This is considered safer than merging, but merging can be turned back on in the settings.


  • Fix PHP warnings


  • Resolve issue with inline CSS not being included
  • Add ability to break merged files based on inline scripts/styles
  • Set plugin minimum PHP version to 7.0


  • Fix inline css and js not being enqueued correctly
  • Disable inlining small CSS files


  • Add MMR version to generated files – ensures plugin updates are applied
  • Multisite files now use seperate directories – fixes purging issues


  • Resolved an issue with inline scripts not working correctly.


  • Remove depreciated warning notices about variables set that aren’t defined


  • file_put_contents: added the LOCK_EX flag when writing to prevent anyone else writing to the file at the same time
  • added modify_js_output_before_save and modify_css_output_before_save filters – Thanks to mewcrazy


  • Add support for a decoupled WordPress configuration – Thanks to AbdulRaheem


  • Upgrade Closure and PHP Minify


  • Added ability to disable merging WordPress Global Styles
  • Fixed issue with missing WordPress Global Styles


  • Fix „String offset cast occurred“ php notice


  • Fix css minmax minifying incorrectly


  • Upgrade Closure and PHP Minify


  • Fix issue with css inline svgs breaking


  • Ensure push urls include scheme for backwards compatability


  • Disable push for external files


  • Disable Google Closure Javascript minification with MMR_USE_CLOSURE constant
  • Disable removing expired files with MMR_REMOVE_EXPIRED constant
  • Enable push for ignored files


  • Disable MMR when using WordPress Customiser


  • Fix issue where JS/CSS would minify even if minification has been disabled


  • Upgraded to latest version of closure
  • Re-enabled HTTP2 push for when the server supports it


  • Prevent php warning showing when handle path is invalid


  • Fix Reported Security Vulnerability
  • Upgrade Minify to latest version


  • Prevent error if mbstring php extension isn’t installed. Thanks @zelon


  • Convert Western Latin 1 Encoding to UTF8
  • Added upgrade notice callback for future use


  • Fixed Undefined variable: ext (thanks to @imsadhappy)
  • Changed HTTP2 push to only preload


  • Fixed issue with invalid file size calculations


  • Fixed issue with merge_minify_refresh_done action not working correctly


  • Code Cleanup
  • Added ability to http2 push CSS or JS seperately
  • Improved reliability of minification + added hourly cron to check
  • Fix issue with mmr_minify action running multiple times


  • Added should_mmr filter and split DIVI, Beaver Builder and Visual Composer checks into seperate plugins
  • Code Cleanup
  • Fix warning when running wp.cron.php directly
  • Prevent failed to open stream error
  • Added merge_minify_refresh_merged action


  • Disable MMR when Divi theme is enabled and page is being edited
  • Disable MMR when Beaver Builder is in use and page is being edited
  • Upgrade Google Closure to the latest version
  • Upgrade PHP Minify to the latest version
  • Add check to see if @import is used in CSS file.


  • Upgraded Closure to latest version
  • Fixed MMR so it works when WordPress and wp-content are in non-standard locations
  • Fixed MMR admin unecessarily updating log text


  • Upgraded Minify and Closure to latest versions


  • Fix for PHP < 7. Thanks to @Roy


  • Fix for incorrect function name


  • Multisite URL Fixes
  • Added action that fires when JS or CSS has updated. Thanks to @lucasbustamante
  • Update Closure to latest


  • Update Java detection for Java 9+
  • Clear scheduled hooks on purge and plugin deactivation
  • Update Closure to latest


  • Multisite Network Support


  • Closure now works with string continuations (removed compatibility code)
  • Fix potential bug with minification


  • Fix issue with Last Accessed
  • Fix issue with css files not being enqueued


  • Fix issue with wp_localize_script data not being set correctly


  • Massive code cleanup.
  • Disable MMR in frontend edit mode of Visual Composer


  • Ensure enqueued css/js have unique handles (fix for NEX-Forms)


  • Updated Closure and Minify to latest versions
  • Code cleanup
  • MMR now checks file extension so that plugins that enqueue php files work (motopress etc.)


  • Added Support for Gonzales. (


  • Fix WordPress in subfolder identification issue. (Bedrock compatibility – Thanks plankguy)


  • Fix usage of clone for php7 compatibility check (Thanks for the heads up mariodabek)


  • Improve CSS concatenation (Thanks to fhoech)


  • older versions of gzip don’t have the -keep flag


  • Fix HTTP2 server push only adding header for one file & ignoring settings


  • Added the ability to generate .css.gz & .js.gz files (Thanks to Marcus Svensson)


  • Fix strange characters message when activating plugin


  • Improvements to http2 push (thanks to Daniel Aleksandersen –


  • Initialise wp_scripts & wp_styles if they haven’t loaded (Thanks Andrew Miguelez)
  • Replace depreciated wp_clone with clone
  • Improved java detection
  • Upgrade to latest version of Minify
  • Upgrade to latest version of Closure


  • Ability to seperate cache urls for javascript and CSS (MMR_JS_CACHE_URL & MMR_CSS_CACHE_URL)


  • Fix concatenation bug (thanks fhoech)


  • Better support for CSS output to the page. This should fix some themes that break.
  • Ability to specify cache directory added. Thanks to Daniel Aleksandersen for help with this.
  • Minor code cleanup


  • Fix External Styles/Scripts ordering


  • Check Java version is sufficient for Google Closure to work


  • Fix bugs introduced by 1.6.4


  • Fix bugs introduced by 1.6.4


  • Fix MMR when WordPress installed in a sub folder


  • Ignore conditional scripts and styles


  • Upgraded Minify to latest version
  • Upgraded Closure to latest version


  • MMR looks for non minified scripts and styles by default (eg. script.min.js = script.js). If found it will use them. This improves compatibility and can fix minification errors.


  • Option to enable http2 server push (thanks to Daniel Aleksandersen –
  • Option to enable output buffering for compatability and so footer scripts can be HTTP2 pushed
  • Ability to turn off minification
  • Ability to turn off concatination
  • Reduced plugin memory usage by only including Minify when required
  • Ability to manually ignore scripts or css
  • Changed hashes from md5 to adler32 as it is faster


  • Upgrade Minify to latest version


  • Only load admin js & css on the mmr options page


  • Display last accessed date in admin
  • Remove unused variables
  • Option to turn off merging


  • Fix wrong variable name


  • Append ; to merged script files to prevent javascript errors


  • woocommerce compatability


  • Remove unused code in insepect_scripts()
  • Resolved issues with late enqued scripts and styles
  • Changed code for removal of string continuations
  • Stopped dequeing styles and scripts as we now use done


  • Process styles/scriptes enqued within body of page in the footer
  • Prevent scripts enqued within body of page outputting twice
  • Clear previous processed files fully when purge all clicked


  • Bugfix


  • Only write admin ajax response when it has changed
  • CSS now compressed using Minify
  • JS compressed with Minify when Closure not available


  • Don’t remove unminified files anymore for rare occasions when css or js return a 404 error
  • Admin now updates automatically.


  • Fix issue with scripts failing to compile because of remove_continuations


  • Fix bug when javascript and css has same handle


  • Bugfix


  • Remove Javascript String Continuations
  • Show queued scripts/css in admin
  • Prevent YUI Compressor stripping 0 second units (minified transitions now work)


  • Ensure file paths are absolute
  • Use ABSPATH instead of DOCUMENT_ROOT


  • Ignore CSS url paths that start with http


  • Minor code refactoring and cleanup


  • Log error when exec not available
  • Fix remote url detection
  • Fix admin header redirect


  • Initial Release