Make WordPress Core


Ignore:
Timestamp:
01/11/2026 06:34:57 AM (2 months ago)
Author:
westonruter
Message:

Themes: Use WP_HTML_Tag_Processor to insert the block template skip link instead of JavaScript.

  • The skip link now works when JavaScript is turned off.
  • By removing the script, the amount of JavaScript sent to the client is reduced for a very marginal performance improvement.
  • A new wp-block-template-skip-link stylesheet is registered, with minification and path data for inlining.
  • The CSS for the skip link now has an RTL version generated, although it is not yet served when the styles are inlined. See #61625.
  • The wp_enqueue_block_template_skip_link() function now exclusively enqueues the stylesheet since the script is removed.
  • For backwards-compatibility, the skip link will continue to be omitted if the_block_template_skip_link() is unhooked from the wp_footer action or wp_enqueue_block_template_skip_link() is unhooked from wp_enqueue_scripts.

Developed in https://github.com/WordPress/wordpress-develop/pull/10676

Follow-up to [56932], [51003].

Props rutviksavsani, westonruter, dmsnell, whiteshadow01, Slieptsov.
See #59505, #53176.
Fixes #64361.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/script-loader.php

    r61442 r61469  
    16061606    $styles->add( 'customize-preview', "/wp-includes/css/customize-preview$suffix.css", array( 'dashicons' ) );
    16071607    $styles->add( 'wp-empty-template-alert', "/wp-includes/css/wp-empty-template-alert$suffix.css" );
     1608    $skip_link_style_path = WPINC . "/css/wp-block-template-skip-link$suffix.css";
     1609    $styles->add( 'wp-block-template-skip-link', "/$skip_link_style_path" );
     1610    $styles->add_data( 'wp-block-template-skip-link', 'path', ABSPATH . $skip_link_style_path );
    16081611
    16091612    // External libraries and friends.
     
    18011804        'wp-pointer',
    18021805        'wp-jquery-ui-dialog',
     1806        'wp-block-template-skip-link',
    18031807        // Package styles.
    18041808        'wp-reset-editor-styles',
Note: See TracChangeset for help on using the changeset viewer.