Make WordPress Core


Ignore:
Timestamp:
05/11/2021 09:41:48 AM (3 years ago)
Author:
gziolo
Message:

Editor: Enqueue script and style assets only for blocks present on the page

Adds styles for individual core blocks to make it possible to render only styles for those blocks that are rendered on the page (frontend). This is optinal functionality for start that can be controlled with the new separate_core_block_assets filter.

In addition to that, styles can be inlined when path is passed when registering an individual styles. This functionality can be changed with the new styles_inline_size_limit filter. The maximum size of inlined styles in bytes defaults to 20 000.

Props aristath, aduth, westonruter, mcsf.
Fixes #50328, #52620.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/default-filters.php

    r50629 r50836  
    552552add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );
    553553
     554add_action( 'wp_head', 'wp_maybe_inline_styles', 1 ); // Run for styles enqueued in <head>.
     555add_action( 'wp_footer', 'wp_maybe_inline_styles', 1 ); // Run for late-loaded styles in the footer.
     556
    554557// Taxonomy.
    555558add_action( 'init', 'create_initial_taxonomies', 0 ); // Highest priority.
Note: See TracChangeset for help on using the changeset viewer.