Skip to content
G GBTI

Disabling Minification on Core WordPress JavaScript Files | GBTI

  • devops
  • frameworks
  • wordpress
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.

We hope you enjoyed this article by Hudson Atwell, GBTI Member.

Python, NextJS, NodeJS, JavaScript, PHP, WordPress, Developer Relations, Novelty, Curation, DevOps, Blockchain, IoT, and more.

A creator co-op, powered by Git

Join the GBTI Network

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

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

A 90-day limited-access trial lets you evaluate the community before you pay. Paid membership is $150 per year and 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.

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.

Written by

Hudson Atwell

Gethsemane, LLC Published 28th Jun 2024

View profile
Contribution history
No tracked contributions yet. A member who improves this article through an accepted pull request earns a share of the revenue it generates.

Imported from the legacy WordPress site, so the earliest edits live there. Everything since is tracked here as member contributions.

Full history on GitHub Spotted something? Become a member to contribute.

Related posts

Sign in with the GBTI extension

Signing in and publishing happen through the free GBTI browser extension. It keeps your GitHub sign-in on your own machine and lets you edit and publish in place.

The Chrome Web Store listing is coming soon. For now, the download page walks you through loading it as an unpacked extension.