WordPress.org

Make WordPress Core

Opened 7 months ago

Last modified 5 months ago

#52879 new defect (bug)

The SCRIPT_DEBUG constant is ignored when concatenating scripts

Reported by: azaozz Owned by:
Milestone: 5.9 Priority: normal
Severity: minor Version: 2.8
Component: Script Loader Keywords:
Focuses: Cc:

Description

Happens because SCRIPT_DEBUG is usually defined in wp-config.php however that file is not used in load-scripts.php and load-styles.php. This results in non-minified files being concatenated and outputted when SCRIPT_DEBUG is false and WP runs from /src.

Attachments (1)

52879.patch (2.8 KB) - added by azaozz 7 months ago.

Download all attachments as: .zip

Change History (7)

#1 @azaozz
7 months ago

It seems this has been largely unnoticed as was very rare to need to load minified files when running from /src. However tests now run from /src and it seems minified files should be able to be used when testing. That can be done with SCRIPT_DEBUG = false.

@azaozz
7 months ago

#2 @azaozz
7 months ago

In 52879.patch: The long way of doing this. Pass SCRIPT_DEBUG to load-scripts.php and load-styles.php so script loader would properly choose the minified files. A shorter way may be to just assume SCRIPT_DEBUG is set to false when running from /src and concatenation (load-scripts.php or load-styles.php) is used.

#3 @TobiasBg
7 months ago

Is there a guarantee that (up-to-date) minified files exist in /src?

#4 @azaozz
7 months ago

No guarantee. Up-to-date js and minified files (and some php files) would exist in /src only after npm run dev (to "watch") or npm run build:dev has been run. This is a problem and there are few tickets about it. But thinking being able to run from /src with SCRIPT_DEBUG = false should work properly in any case.

#5 @isabel_brison
7 months ago

Tested the patch and minified scripts are now being loaded correctly when SCRIPT_DEBUG is false.

Up-to-date js and minified files (and some php files) would exist in /src only after npm run dev (to "watch") or npm run build:dev has been run.

Is it a problem though? The default local environment setup requires npm run build:dev to be run anyway.

#6 @hellofromTonya
5 months ago

  • Milestone changed from 5.8 to 5.9

Today is a freeze for 5.8 as it's Beta 1 day. As discussion is ongoing, punting to 5.9.

Note: See TracTickets for help on using tickets.