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

Assets: Fix defer for async scripts #23928

Merged
merged 6 commits into from
Apr 18, 2022
Merged

Conversation

tyxla
Copy link
Member

@tyxla tyxla commented Apr 13, 2022

I've noticed that whenever we register a script as async, it will add a defer attribute to the translations script tag that is rendered before the enqueued script tag.

This PR fixes that behavior so we defer the script we enqueued instead.

I'm also adding a couple of tests to confirm that the behavior is working as expected.

Changes proposed in this Pull Request:

Assets: Defer the enqueued script instead of its translations

Jetpack product discussion

No related product discussion

Does this pull request change what data or activity we track or use?

No

Testing instructions:

  • Verify package tests pass.
  • Verify that if you add async => true to a script you register, defer will be added to the script and not to its translations.

@tyxla tyxla added [Type] Bug When a feature is broken and / or not performing as intended [Status] Needs Review To request a review from Crew. Label will be renamed soon. [Package] Assets labels Apr 13, 2022
@tyxla tyxla requested a review from a team April 13, 2022 15:55
@tyxla tyxla self-assigned this Apr 13, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Apr 13, 2022

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.

@tyxla tyxla force-pushed the fix/assets-defer-with-translations branch from 5c600b8 to 6aa0381 Compare April 14, 2022 08:09
tyxla and others added 2 commits April 14, 2022 11:10
Co-authored-by: Brad Jorsch <anomiex@users.noreply.github.com>
@tyxla
Copy link
Member Author

tyxla commented Apr 14, 2022

Thanks for the feedback @anomiex! I've addressed it and added several comments to suppress false positive phpcs errors.

Ready for another look.

@tyxla tyxla requested review from anomiex and a team April 14, 2022 08:25
Copy link
Contributor

@anomiex anomiex left a comment

Choose a reason for hiding this comment

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

Let's go for it

@anomiex anomiex added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Apr 18, 2022
@tyxla tyxla merged commit f9c8a99 into master Apr 18, 2022
@tyxla tyxla deleted the fix/assets-defer-with-translations branch April 18, 2022 14:48
@github-actions github-actions bot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Assets [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants