Make WordPress Core

Opened 3 years ago

Last modified 2 years ago

#52879 new defect (bug)

The SCRIPT_DEBUG constant is ignored when concatenating scripts

Reported by: azaozz's profile azaozz Owned by:
Milestone: Future Release Priority: normal
Severity: minor Version: 2.8
Component: Script Loader Keywords: needs-patch needs-testing needs-refresh
Focuses: javascript Cc:


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 3 years ago.

Download all attachments as: .zip

Change History (12)

#1 @azaozz
3 years 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.

3 years ago

#2 @azaozz
3 years 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
3 years ago

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

#4 @azaozz
3 years 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
3 years 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
3 years 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.

This ticket was mentioned in Slack in #core by audrasjb. View the logs.

3 years ago

#8 @audrasjb
3 years ago

  • Milestone changed from 5.9 to 6.0

As per today's bug scrub, let's move this ticket to the next milestone for proper review/refresh.

This ticket was mentioned in Slack in #core by mike. View the logs.

2 years ago

#10 @peterwilsoncc
2 years ago

  • Focuses javascript added
  • Keywords needs-patch needs-testing needs-refresh added

This was discussed during a bug scrub.

Are there any related tickets/test cases that can be provided to further demonstrate when this bug is happening. Is there a general effect or is the effect only evident when testing?

The code generally looks good but in the script-loader file changes, it would be good to switch to the

 * multi-line comments format
 * defined by the WP coding standards

#11 @peterwilsoncc
2 years ago

  • Milestone changed from 6.0 to Future Release

I've moved this to a future release as it hasn't seen the needed review/refresh during this cycle.

Note: See TracTickets for help on using tickets.