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 community. Browse, follow, and save across the network for free, no card required. Join a paid tier to take part and share in the revenue.

Network Member ($50/year): post comments across the network; full Discord access; read members-only content and comment bodies; and see the member-only Shares stream. Earn 10% for life on the paid revenue of members you invite.
Content Creator ($150/year): everything in Network Member, plus publish articles, products, and prompts; post to the member Shares stream; your creator profile and unified portfolio; and reshare and syndicate your work. Content Creators share in the revenue program.
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

Get the weekly digest

One email a week: new member articles, projects and prompts, plus the developer news worth reading. Unsubscribe in one click, any time.

We send a confirmation email first. You are not subscribed until you click the link in it. Read the privacy policy.

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

Comments are for members. Become a member to join the conversation, or if you already are.

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.