Skip to content

Position block support: derive container class from styles so identical rules are deduplicated #83559

Description

@mukeshpanchal27

What problem does this address?

gutenberg_render_position_support() builds its container class from a per-request counter:

<?php
$class_name = wp_unique_id( 'wp-container-' );

Every block instance with position support therefore gets its own class and its own rule in the block-supports style engine store, even when the resulting CSS is byte-for-byte identical.

The other block supports that emit a scoped rule derive the class from the style inputs, so identical styles collapse into one rule:

$class_name = wp_unique_id_from_values( $parsed_block, 'wp-custom-css-' );

Impact

With 200 Group blocks that all use position: sticky; top: 0px:

Rules in store Generated CSS
trunk 200 22,092 bytes
patched 1 116 bytes

This CSS is inlined into every front-end response, so the duplication adds page weight on every request, on top of the render cost.

WordPree core trac ticket: https://core.trac.wordpress.org/ticket/66200

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

[Feature] LayoutLayout block support, its UI controls, and style output.[Status] In ProgressTracking issues with work in progress[Type] PerformanceRelated to performance efforts

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions