Make WordPress Core

Opened 3 months ago

Closed 3 months ago

Last modified 3 months ago

#64122 closed defect (bug) (fixed)

Interactivity API: Add data-wp-router-region directive to the script modules of interactive blocks

Reported by: luisherranz's profile luisherranz Owned by: luisherranz's profile luisherranz
Milestone: 6.9 Priority: normal
Severity: normal Version:
Component: Interactivity API Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

WordPress 6.9 will introduce a new client-side navigation algorithm that starts loading JavaScript when you navigate between pages. However, loading script modules from non-interactive blocks during navigation isn't safe and could cause errors or unexpected behavior. To support this new navigation algorithm, we need a way to identify which script modules belong to interactive blocks in the HTML. This lets the Interactivity API router determine which modules it can safely load during client-side navigation and which ones it should skip.

Change History (4)

This ticket was mentioned in PR #10357 on WordPress/wordpress-develop by @luisherranz.


3 months ago
#1

  • Keywords has-patch has-unit-tests added

This PR uses the wp_script_attributes filter to add the data-wp-router-options directive with the loadOnClientNavigation: true property for all interactive blocks that are compatible with client-side navigation.

Trac ticket: https://core.trac.wordpress.org/ticket/64122

Related Gutenberg PR: https://github.com/WordPress/gutenberg/pull/72449

@luisherranz commented on PR #10357:


3 months ago
#2

Thanks @westonruter!

This should be ready for a final review now.

#3 @luisherranz
3 months ago

  • Owner set to luisherranz
  • Resolution set to fixed
  • Status changed from new to closed

In 61019:

Interactivity API: Support for loadOnClientNavigation.

Uses the wp_script_attributes filter to add a data-wp-router-options directive with a loadOnClientNavigation: true property for all the interactive blocks that are compatible with client-side navigation to let the Interactivity API router determine which modules it can safely load during client-side navigation.

Props luisherranz, westonruter.
Fixes #64122.

@luisherranz commented on PR #10357:


3 months ago
#4

No problem, I've already done it myself. Thanks a lot, Weston!

Committed in https://github.com/WordPress/wordpress-develop/commit/edaed03e22701b76e1c524084808527382da9aee (r61019).

Note: See TracTickets for help on using tickets.