Enhancing the WP_Scripts API With a Loading Strategy#4391
Enhancing the WP_Scripts API With a Loading Strategy#439110upsimon wants to merge 561 commits intoWordPress:trunkfrom
Conversation
|
Hi @10upsimon! 👋 Thank you for your contribution to WordPress! 💖 It looks like this is your first pull request to No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making. More information about how GitHub pull requests can be used to contribute to WordPress can be found in this blog post. Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook. If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook. The Developer Hub also documents the various coding standards that are followed:
Thank you, |
felixarntz
left a comment
There was a problem hiding this comment.
I'll do a more detailed review soon, but just noting a few small things I spotted going over the code for early consideration.
|
When reviewing this PR, I was noticing how methods in @adamsilverstein Do you know why these functions weren't utilized in |
mukeshpanchal27
left a comment
There was a problem hiding this comment.
Thanks @10upsimon, Left some nit-pick feedback.
…ere is a defer dependency
…dling-redux Improve handling of delayed strategies when dependency aliases (bundles) are involved
…into feature/enhance-wp-scripts-api-with-a-loading-strategy * 'trunk' of https://github.com/WordPress/wordpress-develop: (30 commits) Themes: Inline render blocking CSS `classic-themes.css' Bundled Themes: Remove `load_theme_textdomain()` calls from default themes. I18N: Allow to short-circuit `load_textdomain()`. Coding Standards: Use strict comparison in `wp-includes/pomo/entry.php`. Themes: add wp_get_remote_theme_patterns function. Tests/Build tools: Various term related test improvements. Posts, Post Types: Introduce `item_trashed` post type label. Tests/Build tools: Add `@covers` annotation to `wp_set_object_terms()` tests. Taxonomy: Prevent deprecation notices clearing terms. Build/Test Tools: Revert accidental change to .env Media: Update admin image editor design. Docs: Use third-person singular verbs in various function descriptions, as per docblocks standards. Docs: Use third-person singular verbs in various function descriptions, as per docblocks standards. Docs: Use third-person singular verbs in various function descriptions, as per docblocks standards. Fix lint issues in WP_Theme_JSON::sanitize method. Coding Standards: Use strict comparison in `wp-includes/class-wp-oembed.php`. Twenty Seventeen: Improve Grid View variation rendering in the editor for the Post List block. Ignore unregistered block style variations from `theme.json`. Docs: Use third-person singular verbs in various function descriptions, as per docblocks standards. Editor: Skip file_exist check for core blocks. ...
westonruter
left a comment
There was a problem hiding this comment.
I feel good about the current state. But I'm biased.
spacedmonkey
left a comment
There was a problem hiding this comment.
Marking as ready to commit 🎉
Yep, seems ready to commit except the code that re-adds support for "script after". I agree the discussion about adding that code can continue during beta, and if the decision is to continue to promote outdated, mediocre JS architecture it can be committed then. However I'm against adding that in the initial commit. No matter how I look at it, it doesn't make sense to keep promoting this outdated method instead of asking the developers to transition to more modern JavaScript. This seems like a pretty bad "step backwards" from a code architecture point of view. (As the code that adds support for "script after" is still in this PR, I'm not removing the "changes requested" label.) |
This remove support for script handles with inline scripts attached to be loaded with either an `async` and `defer` strategy. Instead, they will be converted to a blocking strategy. This also consolidates logic for determining eligible loading strategies into a new private method, `WP_Scripts::filter_eligible_strategies`, which is responsible for recursively eliminating possible loading strategies. This removes duplication of logic that previously was in place for checking the eligible strategy of a handle with checking for whether dependents could be deferred. `WP_Scripts::has_only_deferrable_dependents` had been removed as it is now unnecessary. Unit tests are updated. Co-authored-by: Simon Dowdles <simon.dowdles@get10up.com>
|
@azaozz, I've removed the support for inline "after" scripts and would appreciate another look. What this means is that now any script handle that is registered with an |
felixarntz
left a comment
There was a problem hiding this comment.
@10upsimon @joemcgill Looks great! A few minor nit-picks, but none of them strictly a blocker.
Co-authored-by: Felix Arntz <felixarntz@users.noreply.github.com>
Sorry for the delay, was afk dealing with some family stuff. The commit LGTM, thanks! |
|
For those whom might be using PHP >= 8.0's named arguments, this will break in WordPress 6.3.0.
I would suggest implementing a stub in your code until you've had time to resolve potential issues. Just calling it out for those who might come looking. |
Trac ticket: https://core.trac.wordpress.org/ticket/12009
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.