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

Non_Blocking_Scripts_Check: Warn about enqueued scripts that use neither defer nor async #467

Closed
adamsilverstein opened this issue Jun 5, 2024 · 1 comment · Fixed by #519
Assignees
Labels
Checks Audit/test of the particular part of the plugin [Team] Performance Issues owned by Performance Team [Type] Enhancement A suggestion for improvement of an existing feature
Milestone

Comments

@adamsilverstein
Copy link
Member

As proposed by @felixarntz in #443, this check would help encourage user to switch to non blocking enqueues.

Potentially we could also accept a blocking script as long as it's $in_footer. But it would definitely warn about a blocking in head script.

@swissspidy pointed out that The corresponding PHPCS sniff does not yet support the new $args param we added in 6.3. It was also indicated that the sniff might actually be removed because it's harder to detect. So probably needs to be a runtime check.

@adamsilverstein adamsilverstein added [Type] Enhancement A suggestion for improvement of an existing feature Checks Audit/test of the particular part of the plugin labels Jun 5, 2024
@adamsilverstein adamsilverstein changed the title Non_Blocking_Scripts_Check: Would warn about enqueued scripts that use neither defer nor async. Potentially Non_Blocking_Scripts_Check: Would warn about enqueued scripts that use neither defer nor async. Potentially Jun 5, 2024
@swissspidy swissspidy added the [Team] Performance Issues owned by Performance Team label Jun 6, 2024
@swissspidy swissspidy changed the title Non_Blocking_Scripts_Check: Would warn about enqueued scripts that use neither defer nor async. Potentially Non_Blocking_Scripts_Check: Would warn about enqueued scripts that use neither defer nor async Jun 6, 2024
@adamsilverstein adamsilverstein changed the title Non_Blocking_Scripts_Check: Would warn about enqueued scripts that use neither defer nor async Non_Blocking_Scripts_Check: Warn about enqueued scripts that use neither defer nor async Jun 6, 2024
@swissspidy
Copy link
Member

We can probably use Enqueued_Scripts_Size_Check as a base and then simply check $script->extra['strategy'] of all the enqueued scripts.

Related:

We might want to have an abstract class for shared logic to reduce repetition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Checks Audit/test of the particular part of the plugin [Team] Performance Issues owned by Performance Team [Type] Enhancement A suggestion for improvement of an existing feature
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants