Skip to content

Add non-configurable exclusion list for known incompatible scripts#82

Closed
mreishus wants to merge 1 commit into
mainfrom
add/exclusion-list
Closed

Add non-configurable exclusion list for known incompatible scripts#82
mreishus wants to merge 1 commit into
mainfrom
add/exclusion-list

Conversation

@mreishus
Copy link
Copy Markdown
Contributor

@mreishus mreishus commented Nov 21, 2024

Summary
Creates a hardcoded list of scripts known to break concatenation, starting with MonsterInsights which requires type="module". Unlike the configurable exclusion list, this applies to all installations regardless of user settings.

Background
MonsterInsights modifies its script tag to type="module" via script_loader_tag filter, which breaks when concatenated because the concatenated version loses this attribute, and uses ES6 import statements that require it. Found here: 9017084-zd-a8c

Possible Approach 1: Add to default exclusion list

  + Simple, uses existing mechanism
  - Only works for new installations or default settings. Anyone who has tweaked doesn't get the fix.

Possible Approach 2: Detect module scripts by running script_loader_tag filter and checking results.

  + Catches all module scripts using this technique automatically
  - Some runtime overhead checking script tags
  - Not sure how popular this pattern actually is.

Current Approach 3: Known incompatible list

  + Works for all installations regardless of settings
  + Very little runtime overhead
  + Clear separation between user and compatibility exclusions
  - Requires code changes for new conflicts

Steps to Reproduce

  • On a site, install and activate both page-optimize and MonsterInsights.
  • Visit homepage.
  • Check browser console for: Uncaught SyntaxError: import declarations may only appear at top level of module.

To verify fix

  • Reproduce the problem
  • apply the patch
  • visit the homepage
  • the SyntaxError seen above should no longer appear.

@mreishus mreishus self-assigned this Nov 21, 2024
@mreishus
Copy link
Copy Markdown
Contributor Author

This should not be needed after #107 stops concat for script-loader-tag changed scripts.

@mreishus mreishus closed this Feb 11, 2026
@mreishus mreishus deleted the add/exclusion-list branch February 11, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant