Script Modules API: Move the script modules to the footer in classic themes#1
Closed
luisherranz wants to merge 7 commits intorename-module-functions-to-script-modulesfrom
Closed
Conversation
6 tasks
7d48527 to
0871981
Compare
Co-authored-by: Weston Ruter <westonruter@google.com>
…ints functionality
0871981 to
a7eaf39
Compare
9f1af46 to
c1a6909
Compare
Owner
Author
|
Now that WordPress#5869 was committed, I moved this PR to WordPress Core: |
luisherranz
pushed a commit
that referenced
this pull request
Oct 20, 2025
…Info screen.
This resolves a fatal error if `strict_types` PHP setting is enabled:
{{{
Argument #1 ($num) must be of type float, string given
}}}
Since the goal of the Site Health Info screen is to display raw values where possible, the `number_format()` call here does not seem to provide any benefit.
Props krishneup, sabernhardt, audrasjb, SergeyBiryukov.
Fixes #60364.
git-svn-id: https://develop.svn.wordpress.org/trunk@58847 602fd350-edb4-49c9-b593-d223f7449a82
luisherranz
pushed a commit
that referenced
this pull request
Oct 20, 2025
…ord()`.
This resolves a "passing null to non-nullable" deprecation notice on PHP 8.1+:
{{{
Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated
}}}
Follow-up to [50129], [54477].
Props afragen, peterwilsoncc, SergeyBiryukov.
Fixes #62298.
git-svn-id: https://develop.svn.wordpress.org/trunk@59312 602fd350-edb4-49c9-b593-d223f7449a82
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trac ticket: https://core.trac.wordpress.org/ticket/60240
!! This is built on top of WordPress#5869. For that reason it's still a local PR. I will rebase it and open a PR in the
WordPress/wordpress-developonce WordPress#5869 is merged.What
Moves the script module prints to the footer in classic themes. It also removes the ability to call the print functions more than once because it's now unnecessary.
Why
In the ticket that introduced the Script Modules API (#56313), I added a logic that prints as many enqueued and preloads as possible in the head, then prints the remaining ones in the footer and includes the import map. I explain my reasoning in this comment.
But @cbravobernal realized that import maps fail if they appear after the modules. That means that there's no other way but printing the import map first, and then all the modules and preloads (yes, preloads also fail!). So we need to check if we are on a classic or block theme, and if we are in a classic theme, move everything to the footer.
How
By leveraging
wp_is_block_theme()and moving everything to the footer in classic themes:Additional comments
@westonruter mentioned that we could optimize this in the future if we have a way to filter the output before sending the response to the client: