WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/11/2021 09:41:48 AM (3 months 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/tests/phpunit/tests/blocks/register.php

    r50450 r50836  
    271271        $this->assertSame( 'unit-tests-test-block-style', $result );
    272272        $this->assertSame( 'replace', wp_styles()->get_data( 'unit-tests-test-block-style', 'rtl' ) );
     273
     274        // @ticket 50328
     275        $this->assertSame(
     276            wp_normalize_path( realpath( DIR_TESTDATA . '/blocks/notice/block.css' ) ),
     277            wp_normalize_path( wp_styles()->get_data( 'unit-tests-test-block-style', 'path' ) )
     278        );
    273279    }
    274280
     
    367373        $this->assertSame( 'tests-notice-editor-style', $result->editor_style );
    368374        $this->assertSame( 'tests-notice-style', $result->style );
     375
     376        // @ticket 50328
     377        $this->assertSame(
     378            wp_normalize_path( realpath( DIR_TESTDATA . '/blocks/notice/block.css' ) ),
     379            wp_normalize_path( wp_styles()->get_data( 'unit-tests-test-block-style', 'path' ) )
     380        );
    369381    }
    370382
Note: See TracChangeset for help on using the changeset viewer.