Skip to content

enqueue_block_assets hook loads scripts twice #53590

Description

@wpsoul

Description

Latest update gives us option to load some scripts and styles in Iframe, which is great.

The problem is that it's loading everything twice in the Site editor - outside iframe and inside iframe. This makes some scripts execute twice and break them

Is it possible to load only in an iframe on the Site editor? I think it can be correct if we check if current page has iframed content and if yes, then we load only in an iframe, if not, we load outside iframe

Step-by-step reproduction instructions

  1. Use enqueue_block_assets and add wp_enqueue_script
  2. Open Site editor
  3. Check the page source code. The script is added to the page content.
  4. Add console.log('test') to script
  5. We see that it's triggered twice on the Site editor pages

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions