Skip to content
GBTI

Disabling Minification on Core WordPress JavaScript Files | GBTI

Disabling Minification on Core WordPress JavaScript Files | GBTI

Sometimes, it becomes necessary to edit core WordPress files directly, inside a non production environment, to better understand the behavior of the WordPress platform and pinpoint specific problems. By default, WordPress combines and compresses its JavaScript files to improve performance, but this can make it difficult to trace issues or make modifications.

This tutorial will guide you through the steps to disable these features, allowing you to work with the original, unminified files.

Editing wp-config.php directly to disable minification.

To disable script concatenation and compression, add the following lines to the wp-config.php file:

define('CONCATENATE_SCRIPTS', false); define('SCRIPT_DEBUG', true);

Editing functions.php directly to disable minifications.

To disable script minification and concatenation via your theme’s functions.php file, add the following code:

add_filter('script_loader_src', 'disable_minification', 10, 2); add_filter('style_loader_src', 'disable_minification', 10, 2); function disable_minification($src, $handle) { if (strpos($src, '.min.') !== false) { $src = str_replace('.min.', '.', $src); } return $src; }

Additional considerations

Direct modification of core WordPress files is generally discouraged due to the following reasons:

  • Changes will be overwritten during updates.
  • It may lead to unexpected behavior if not executed properly.

Preferably, use hooks, filters, or plugins to implement changes. For those needing to directly edit JavaScript files, creating a custom plugin or theme to include the custom scripts is advised.

A creator network, powered by Git

Join the GBTI Network

The GBTI Network is a creator network. Members showcase their work, write articles, share in network profits, and meet in weekly coaching calls with the community.

Publish your profile, blog posts, products, and prompts
Share in network profits
Join weekly coaching calls with the community

Create a free account to browse the community first, no card required. A paid membership unlocks your public presence on the network: your profile, blog, products, and prompts.

Become a member You are reading atwellpub's work. Joining from this page credits atwellpub.

Written by

Hudson Atwell

Gethsemane, LLC Published 29th Jun 2024

View profile

0 Comments

No comments yet. Be the first. Members comment from the GBTI local client, where comments are submitted as pull requests and auto-published for paid members.

Become a member

Members write comments from the GBTI client or browser extension. Become a member to join the conversation.

You are signed in as a member. .

Contribution history

Related posts

Join the GBTI co-op

Saving, collecting, and following are member perks. Sign in with a free GitHub account to keep what you find, and become a member to comment, join the Discord, and unlock members-only content.

Get the extension to edit and publish your work in place.