Skip to content

Plugin Proposal: Stylesheet Optimizer #1834

@westonruter

Description

@westonruter

Overview

  • Proposed plugin name: Stylesheet Optimizer
  • Proposed plugin slug: stylesheet-optimizer
  • Proposed plugin owner GitHub username(s): westonruter

About the plugin

Purpose

When using a classic theme, the stylesheets for blocks are enqueued on every page even when they are not used. Similarly, the main block-library stylesheet is also enqueued rather than enqueueing individual stylesheets for each block that is actually used on the page. This is all wasteful.

Scope

Enable the should_load_separate_core_block_assets filter by default, even for classic themes. Move all styles printed in wp_footer up to the HEAD in the original dependency order as if the filter had not been applied. (See also Core-61965.)

This wouldn't necessarily depend on Optimization Detective since there would be no need for URL Metrics. All that is needed is the output buffering filter that Optimization Detective utilizes, and possibly the use of the HTML Tag Processor (cf. #1546) for removing the footer styles and putting them in the HEAD. Without Optimization Detective, we just need an output buffering mechanism which could replicate same output buffering used in that plugin, or else push to get Core-43258 done for 6.8.

Then again, a subsequent enhancement for this plugin could be to leverage URL Metrics to detect what the critical styles are, so a dependency on Optimization Detective may make sense.

Rationale

The idea for a plugin was raised in a support forum topic by guillermo77.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Not Started/Backlog 📆

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions