Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRAFT: PR for enhancing WP_Scripts with a loading strategy #54

Closed

Conversation

joemcgill
Copy link
Collaborator

⚠️ IMPORTANT This is a draft PR so we can review the diffs between our feature branch and trunk. DO NOT MERGE.

kt-12 and others added 30 commits February 26, 2023 04:43
Co-authored-by: Joe McGill <801097+joemcgill@users.noreply.github.com>
Co-authored-by: Joe McGill <801097+joemcgill@users.noreply.github.com>
Co-authored-by: Joe McGill <801097+joemcgill@users.noreply.github.com>
Co-authored-by: Joe McGill <801097+joemcgill@users.noreply.github.com>
Co-authored-by: Simon Dowdles <72872375+10upsimon@users.noreply.github.com>
Co-authored-by: Simon Dowdles <72872375+10upsimon@users.noreply.github.com>
Co-authored-by: Simon Dowdles <72872375+10upsimon@users.noreply.github.com>
Co-authored-by: Simon Dowdles <72872375+10upsimon@users.noreply.github.com>
Co-authored-by: Joe McGill <801097+joemcgill@users.noreply.github.com>
@westonruter
Copy link
Collaborator

Question: Should this PR also include cases where these new loading strategies are leveraged in core? Or is the thought that the PR be kept purely for the API changes and then to have separate PRs opened that make use of it?

@felixarntz
Copy link
Collaborator

@westonruter The latter, once the API is in core, we can start using it in a few places in core as well as the default themes.

@westonruter
Copy link
Collaborator

westonruter commented Apr 27, 2023

Update: Comment moved to WordPress#4391 (comment).

When reviewing this PR, I was noticing how methods in WP_Scripts construct a lot of <script> tags manually with string concatenation, printf, variable interpolation, and calls to esc_attr()/esc_url(). Since WordPress 5.7, there have been dedicated helper functions (wp_get_inline_script_tag() and wp_get_script_tag()) which do all of the heavy lifting, as well as adding features like allowing the attributes to be filterable (for the sake of CSP). I've opened a draft PR (#58) for this branch which proposes using them. If desired, I can fix up the tests.

@adamsilverstein Do you know why these functions weren't utilized in WP_Scripts when they were introduced? I seem to recall this was punted for a later effort, but I can't find that info off hand.

Copy link
Collaborator Author

@joemcgill joemcgill left a comment

Choose a reason for hiding this comment

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

Small spacing nitpicks

src/wp-includes/script-loader.php Outdated Show resolved Hide resolved
tests/phpunit/tests/dependencies/scripts.php Outdated Show resolved Hide resolved
@10upsimon
Copy link

Small spacing nitpicks

Resolved in recent commit @joemcgill

@joemcgill
Copy link
Collaborator Author

@10upsimon I believe we've wrapped up all blocking feedback on this draft PR at this point. When you're ready, please feel free to open a new PR to merge this branch into the trunk branch of the WordPress repo instead of this fork, and then I'll close this PR. We can pick up conversations about any additional enhancements we want to make (like #58) in the new PR that you open.

@joemcgill
Copy link
Collaborator Author

Closing this in favor of WordPress#4391, but we can still reference the open conversations and pick them up on the new PR opened against the WordPress repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Script Loading Strategy Issues relating to the Script Loading Strategy (WPP)
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

7 participants