Skip to content

Blocks: allow enqueueing frontend js files with custom loading strategies #44547

@jeherve

Description

@jeherve

Since WordPress 6.3, one can enqueue scripts on the frontend of a WordPress site while defining defer or async:
https://make.wordpress.org/core/2023/07/14/registering-scripts-with-async-and-defer-attributes-in-wordpress-6-3/

We currently leverage this for some of our scripts, but not for any of the scripts enqueued alongside blocks:

wp_enqueue_script( 'jetpack-block-' . $type, $view_script, $script_dependencies, $script_version, false );

It would be nice to add that option there. Maybe this is something that should be passed on block registration, in Blocks::jetpack_register_block()?


Related conversation: #44532

the JS for the Subscribe block is a non-defer classic script:

Metadata

Metadata

Assignees

Labels

Enhancement[Focus] BlocksIssues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack[Focus] Performance[Pri] Normal[Type] EnhancementChanges to an existing feature — removing, adding, or changing parts of it

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions