-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use defer loading strategy for frontend view scripts (#52536)
* Load interactivity API scripts with defer loading strategy * Load comment-reply script with defer loading strategy * Load search view script with defer loading strategy * Defer the view scripts for the Navigation and File blocks * Use DCA event instead of window load event for Navigation viewScripts * Optimize submenu-on-click view script * Fully leverage event delegation to allow async loading strategy. * Keep track of whether a submenu is open to short-circuit event handlers. * Use passive event listeners. * Optimize modal view script * Fully leverage event delegation to allow async loading strategy. * Remove event listener for anchor clicks in modal when modal is closed. * Use passive event listeners. * Utilize asset file for wp-block--search-view * Conditionally enqueue navigation view scripts only if needed * Update Navigation block to remove/add view scripts in the same way the File block does * Update Search block to include view script in same way as File block and Navigation block * Refactor Search block view script * Adopt asynchronous loading strategy. * Use event delegation. * Collapse expanded blocks when tabbing out of expanded Search block. * Only attach keydown/keyup event handlers while Search block is expanded. * Ensure search button's aria-label is translated. * Ensure Search button's type is restored to 'button' instead of deleting type (since no type is same as 'submit'). * Use passive event listeners. * Use more DOM properties instead of attributes * Use more precise reflected terminology * Remove resolved TODO comment * Use event delegation to open MicroModal * Remove excessive type check * Fix closing submenus when there are multiple Navigation blocks on a page * Clarify block.json comment * Add core merge note for comment-reply script strategy * Use defer strategy instead of async for Navigation and Search blocks * Defer all block view scripts * Ensure interactivity scripts remain in footer in WP<6.3 * Remove defer from comment-reply for now Co-authored-by: Felix Arntz <[email protected]> --------- Co-authored-by: Felix Arntz <[email protected]>
- Loading branch information
1 parent
eea9e52
commit 6cf6643
Showing
8 changed files
with
410 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.