Skip to content

Icons: Inline the markup of core-admin icons - #14208

Closed
fushar wants to merge 1 commit into
WordPress:trunkfrom
fushar:inline-admin-icons
Closed

fushar wants to merge 1 commit into
WordPress:trunkfrom
fushar:inline-admin-icons

Conversation

@fushar

@fushar fushar commented Oct 12, 2026

Copy link
Copy Markdown

What?

Backports WordPress/gutenberg#84552. Ships a generated PHP file with the SVG markup of the core-admin icons, and makes the icons registry use it.

Why?

#12270 replaces the Dashicons in the admin menu and admin bar with core-admin/* icons. Every admin page then reads about 20 SVG files from disk and runs wp_kses() on each of them, a cost the CSS-based Dashicons never had. This was raised in review.

These icons ship with core, so their markup is trusted and only changes with a release. Inlining it removes both the file reads and the sanitization.

How?

  • src/wp-includes/assets/icon-library-inlined-icons.php maps each core-admin/* icon name to its SVG markup. It is generated in Gutenberg and copied by a new copy:icon-library-inlined-icons step in build:gutenberg, next to the icon manifest.
  • WP_Icons_Registry::get_content() returns the inlined markup when the icon name is in that file and its file_path is inside wp-includes/images/icon-library/. An icon registered under the same name from another location still has its file read and sanitized.

The inlined markup is the file content with the whitespace between tags removed. Compared to the sanitized output it keeps viewBox in its original casing; wp_kses() lowercases it.

In a local Docker environment without opcache, on top of #12270, this takes the first render of the 20 admin icons from about 6 ms to about 1 ms. This is a micro-benchmark of the icon calls, not a page load profile.

Testing Instructions

Run npm run test:php -- --group icons. The new tests check that every inlined icon exists in the manifest, that its markup is equivalent to its sanitized file, and that the registry serves it.

Draft notes:

Trac ticket: TBD

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Used for: Implementation, tests and this description; reviewed by me.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Ship a generated file with the SVG markup of the icons in the core-admin
collection, and use it in the icons registry so that these icons are not
read from disk and sanitized on every admin request.

Backports WordPress/gutenberg#84552.
@fushar fushar closed this Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant