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

Create Enqueued_Scripts_Scope_Check #23

Closed
mehulkaklotar opened this issue Nov 21, 2022 · 1 comment · Fixed by #485
Closed

Create Enqueued_Scripts_Scope_Check #23

mehulkaklotar opened this issue Nov 21, 2022 · 1 comment · Fixed by #485
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

Comments

@mehulkaklotar
Copy link
Member

mehulkaklotar commented Nov 21, 2022

Description

Checks that scripts are only enqueued in certain contexts and not just everywhere. While a theme often enqueues scripts or styles that are needed for the entire site, plugins usually have specific behaviors that often do not affect the entire site. Such plugins should not just call wp_enqueue_script() on the wp_enqueue_scripts action, but have conditional logic in there to only enqueue the script when needed based on context. This check would load different contexts (simulating different URLs) of different kinds and warn if a script is enqueued on all of them.

Acceptance Criteria

  • Class Enqueued_Scripts_Scope_Check should be created and exists at includes/Checker/Checks
  • Class Enqueued_Scripts_Scope_Check should extend the Runtime_Check abstract class which extends Check interface
  • Property $violation code should be warning
  • Method run should be implemented from the Runtime_Check abstract class if needed
  • Check_Result $check_result should be used from the run method parameter to append the results

Test Coverage

  • Enqueued_Scripts_Scope_Check class is expected to extend Runtime_Check class
  • Enqueued_Scripts_Scope_Check class is expected to be instance of Runtime_Check class
  • run method expected to append the audit results to $check_result
@mehulkaklotar mehulkaklotar added [Type] Enhancement A suggestion for improvement of an existing feature Checks Audit/test of the particular part of the plugin Infrastructure Issues for the overall plugin infrastructure and removed Infrastructure Issues for the overall plugin infrastructure labels Nov 23, 2022
@mehulkaklotar mehulkaklotar self-assigned this Dec 12, 2022
@mehulkaklotar mehulkaklotar removed their assignment Dec 12, 2022
@swissspidy swissspidy added [Team] Performance Issues owned by Performance Team and removed Milestone 3 labels Jun 6, 2024
@swissspidy
Copy link
Member

swissspidy commented Jul 1, 2024

For the start I suppose we can just copy Enqueued_Styles_Scope_Check for scripts.

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
3 participants