Skip to content

Script Loader: Remove compression constants and related code - #8409

Closed
SainathPoojary wants to merge 16 commits into
WordPress:trunkfrom
SainathPoojary:remove/compression-constants
Closed

SainathPoojary wants to merge 16 commits into
WordPress:trunkfrom
SainathPoojary:remove/compression-constants

Conversation

@SainathPoojary

@SainathPoojary SainathPoojary commented Feb 25, 2025 •

Copy link
Copy Markdown
Member

Remove legacy compression constants (COMPRESS_SCRIPTS, COMPRESS_CSS, ENFORCE_GZIP) and related code.

Before:
Screenshot 2025-02-26 at 12 07 02 PM

After:
Screenshot 2025-02-26 at 12 06 03 PM

Trac ticket: #63017


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@SainathPoojary
SainathPoojary force-pushed the remove/compression-constants branch from 26f3114 to 46fcd92 Compare February 26, 2025 05:09
@SainathPoojary
SainathPoojary marked this pull request as ready for review February 26, 2025 07:49
@github-actions

github-actions Bot commented Feb 26, 2025 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props sainathpoojary, westonruter, azaozz.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@SainathPoojary
SainathPoojary force-pushed the remove/compression-constants branch from 28be79f to 276ed6a Compare June 16, 2025 13:23
@azaozz

azaozz commented Jun 26, 2025

Copy link
Copy Markdown
Contributor

This looks good. I hope I'll have time this weekend to go over it in more details. One thing to note is that the global $compress_scripts and $compress_css as set in script_concat_settings() would still need to exist for full backwards compatibility.

Would it also be possible to remove checking these constants from class-wp-debug-data.php?

westonruter and others added 10 commits October 17, 2026 17:26
Conflicts are resolved by taking trunk's version and reapplying the removal of the compression code and the `c` argument. Trunk has since moved to `wp_print_script_tag()`, made concatenation opt-in through `wp_should_concatenate_admin_scripts()`, and dropped the `type` attributes from the expected markup in the tests. The removal of the `COMPRESS_SCRIPTS` and `COMPRESS_CSS` rows from the debug data merges cleanly, since trunk already removed them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Without an `@global` tag, PHPStan treats `$wp_version` as `mixed`, which it rejects when interpolated into the expected loader URLs (`encapsedStringPart.nonString`). The tags are added in the form other tests in these files already use, ahead of a change to those URLs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two tests added on trunk since this branch was started expect the `c` argument in the load-scripts.php and load-styles.php URLs, which are no longer printed with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Scripts and styles have not been compressed from PHP since 5.0.0, so a default of true claimed compression that never happens. The globals are kept for backward compatibility with code that reads them, and a value set by a plugin is still left alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`SCRIPT_DEBUG` disables only concatenation now, and the result of the compression test no longer affects how scripts and styles are loaded, so the header no longer describes the test or its `can_compress_scripts` option.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing reads `$compress_scripts` anymore, so the cases that differed only in its value were redundant, and the test class no longer needs to back up and restore it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The globals default to false, and the `COMPRESS_SCRIPTS` and `COMPRESS_CSS` constants no longer turn them on, even where the stored result of the compression test used to. A value already set by a plugin is kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The docs standard aligns the types and variable names within a group of tags.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The endpoints already ignore compression parameters, and regression tests cover the updated settings behavior.

No open issues 🎉

What changed in this PR

Removes obsolete compression controls from the script loader while preserving compatibility globals.

Changes:

  • Removes compression parameters from concatenated asset URLs.
  • Defaults compression globals to false without overwriting existing values.
  • Updates URL expectations and adds settings regression tests.
File Description
tests/​phpunit/​tests/​dependencies/​styles.php Updates the expected stylesheet URL and global annotations.
tests/​phpunit/​tests/​dependencies/​scripts.php Updates script URLs and removes obsolete compression test setup.
tests/​phpunit/​tests/​dependencies/​scriptConcatSettings.php Tests compression defaults, ignored constants, and preserved globals.
src/​wp-includes/​script-loader.php Removes legacy compression handling and updates documentation.

Review effort: Balanced

The removal was merged to the 4.9 branch and first released in 4.9.9, ahead of 5.0.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wporg-sync pushed a commit that referenced this pull request Oct 18, 2026
Scripts and styles have not been compressed from PHP since WordPress 4.9.9, when `load-scripts.php` and `load-styles.php` stopped reading the `c` argument in r43580. Even so, the `COMPRESS_SCRIPTS`, `COMPRESS_CSS` and `ENFORCE_GZIP` constants were still documented and read, only to set that unused argument on the loader URLs. That code and documentation are removed.

The `$compress_scripts` and `$compress_css` globals are kept for backward compatibility with code that reads them, but they now default to false since nothing is compressed, and a value already set by a plugin is still left alone. The compression test, which still runs in the admin, is to be removed separately.

Developed in #8409.
Follow-up to r10442, r43580, r64320, r64321.

Props sainathpoojary, westonruter, zodiac1978, dpknauss, azaozz.
See #44815, #57548, #58302, #65980.
Fixes #63017.


git-svn-id: https://develop.svn.wordpress.org/trunk@64485 602fd350-edb4-49c9-b593-d223f7449a82
@github-actions

Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 64485
GitHub commit: acf82f5

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions Bot closed this Oct 18, 2026
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Oct 18, 2026
Scripts and styles have not been compressed from PHP since WordPress 4.9.9, when `load-scripts.php` and `load-styles.php` stopped reading the `c` argument in r43580. Even so, the `COMPRESS_SCRIPTS`, `COMPRESS_CSS` and `ENFORCE_GZIP` constants were still documented and read, only to set that unused argument on the loader URLs. That code and documentation are removed.

The `$compress_scripts` and `$compress_css` globals are kept for backward compatibility with code that reads them, but they now default to false since nothing is compressed, and a value already set by a plugin is still left alone. The compression test, which still runs in the admin, is to be removed separately.

Developed in WordPress/wordpress-develop#8409.
Follow-up to r10442, r43580, r64320, r64321.

Props sainathpoojary, westonruter, zodiac1978, dpknauss, azaozz.
See #44815, #57548, #58302, #65980.
Fixes #63017.

Built from https://develop.svn.wordpress.org/trunk@64485


git-svn-id: http://core.svn.wordpress.org/trunk@63635 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants