WordPress follows a structured approach when loading JavaScript and CSS files. By default, it loads minified versions (.min.js or .min.css) to optimize performance and reduce file sizes. This is a standard for WordPress core files (e.g. the jQuery library), and a practice that is used by WordPress developers. Some plugins have CSS/JS files that have two versions (minified, and unminified, the latter being loaded for debugging purposes. Other plugins have just one version of a file that is either already minified or not minified at all (e.g. some developers just don’t want to bother with multiple versions and minification, for various reasons).
When Does WordPress Load Unminified Files?
1. SCRIPT_DEBUG is Enabled
If SCRIPT_DEBUG is set to true in wp-config.php, WordPress forces the loading of unminified files (this is especially valid for core files)
define('SCRIPT_DEBUG', true);
2. Development Tools & Debugging Plugins
Some debugging plugins or custom development environments may override default behavior and load unminified versions.
3. Plugin Developers Forcing Unminified Scripts
Some WordPress plugins, particularly those with debugging options, might load unminified scripts to help developers troubleshoot issues. Some developers even forget that they had them unminified, and apply changes to their plugin having only non-minified assets loading.
What About Asset Optimization Plugins?
Even if you use an asset optimization plugin like Asset CleanUp, the initial files enqueued by WordPress or a plugin will remain in their original state. Asset CleanUp and similar plugins do not alter which version is initially loaded. They only modify or optimize assets afterward.
Additionally, Asset CleanUp does not attempt to minify files that are already minified in order to save resources. However, if a file is minifiable, Asset CleanUp will attempt to minify it, and it will be referenced from places such as /wp-content/cache/asset-cleanup/.
How to Always Load Unminified Files
1. Enable SCRIPT_DEBUG
Make sure that in wp-config.php (the WordPress configuration file from the root), the constant SCRIPT_DEBUG is set to true, just like in this example:
define('SCRIPT_DEBUG', true);
After you do this, if you still notice the same minified file loading, it means that the plugin developer (of that particular plugin that you want to have unminified loaded files) had only used one version of the file (the minified one).
2. Manually Dequeue jQuery Minified Version and Enqueue Unminified Version
If you want for any reason (e.g. the minified version of a file is fault, breaks functionality, and it needs to be recreated), you can edit your functions.php from your theme or Child theme (recommended, if you have one available), and use a code like the own shown below, which will alter the enqueued asset and make it load the unminified version. This example is for the well known jQuery library. Feel free to adapt it to your needs (e.g. changing the handle names to the ones from your plugin/theme).
add_filter('script_loader_src', function ($src, $handle) {
$new_src = false;
if ($handle === 'jquery-core') {
$new_src = includes_url('/js/jquery/jquery.js'); // New Path to File
}
// If jQuery Migrate is loaded for this environment
if ($handle === 'jquery-migrate') {
$new_src = includes_url('/js/jquery/jquery-migrate.js'); // New Path to File
}
if ($new_src) {
// Preserve the version query parameter if it exists
$parsed_url = wp_parse_url($src);
if ( ! empty($parsed_url['query']) ) {
parse_str($parsed_url['query'], $query_params);
if ( ! empty($query_params['ver']) ) {
$new_src = add_query_arg('ver', $query_params['ver'], $new_src);
}
}
return $new_src;
}
return $src;
}, 10, 2);
How to Check Which Version is Loaded?
To verify whether WordPress is loading the minified or unminified version of a file:
- Open Developer Tools in your browser (F12 → Network tab).
- Filter by the file name (e.g., jquery).
- Check the file path:
– If it ends in .min.js → Minified version is loaded.
– If it ends in .js (without .min) → Unminified version is loaded.
What happens if you enable minification for CSS/JS files in Asset CleanUp?
First, the page will be scanned for any assets that are loading. If it detects any that could be minified (e.g. they are either unminified or partiall minified, and there is room for improvement), it will minify the asset, and store the minified version and load it from a place such as /wp-content/cache/asset-cleanup/. Asset CleanUp will never alter the original file from the theme, the plugin from which it loads or any file from the WordPress core (these ones are already minified, so it’s likely Asset CleanUp will not touch them). There might be situations when the minify feature from Asset CleanUp will not be useful and it’s better to turn it off, to avoid using extra resources in scanning the page’s files, because all the files that are loaded could already be minified. It happens, when the developers of the theme/plugins, were all doing a good job at enqueueing CSS/JS files or loading inline CSS/JS code.Final Thoughts
Loading unminified files is primarily a debugging feature, not an error. If you are seeing unminified files in a production environment, check your SCRIPT_DEBUG setting and any plugins that may be forcing unminified assets. Don’t worry if some plugin developers left there some unminified files (the only ones available), as Asset CleanUp will minify it for you.