Repository navigation
Provide style.min.css for production - #61
Conversation
|
👋 Thanks for your first pull request, @josephscott! We'll take a look soon. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
|
My preference would be to first explore solutions that does not involve more build tools and disabling an established WordPress feature. Which of the custom CSS is actually non negotiable? |
If we end up having a stylesheet, this makes sense to have, but I agree with you that we should challenge that as much as we can. Let's audit the CSS we have and revisit this after if we decide some of it needs to stay. Also, the CSS in theme.json is tied to a block. If I am not mistaken, it will only load when such a block is present, which makes it so we don't have the CSS on every single page unless it's really needed. |
|
Fair point about using the theme editor to edit the This creates a default optimized path for everyone who doesn't edit the Doing this minification step is part of what makes #63 an even better win, where the CSS gets inlined instead of making a separate HTTP request. |
|
@MaggieCabrera what are the current thoughts on this? If the theme is going to continue to have a separate |
e1be70c to
be6f760
Compare
|
@MaggieCabrera what is the latest on this? If we are going to have a |
be6f760 to
b8e945c
Compare
|
I rebased this onto trunk and rebuilt Updated sizes, in bytes:
I also added a CI check that rebuilds |
mikachan
left a comment
There was a problem hiding this comment.
Thanks @josephscott, and thanks @MaggieCabrera for rebasing and adding the CI check.
I'm in favour of this. After the audit, it looks like we're only keeping the CSS that can't be included in theme.json, so shipping a minified copy as well makes sense. It's also the same pattern TT5 uses.
I've left one small, non-blocking suggestion.
9e1e9ff to
3731d1e
Compare
Using the same pattern as the TT5 theme - https://themes.trac.wordpress.org/browser/twentytwentyfive/1.5/package.json - this change adds a `style.min.css` and the tooling around it to build it. The `style.css` file would still be used any time that `SCRIPT_DEBUG` is true - which is the case for the `wp-env` setup used by Ipsum. Production setups would get the benefit of using the smaller `style.min.css` file. For sizes, `style.min.css` comes in at 3,354 bytes. Down from the 9,380 bytes of `style.css`. Here are a few quick compression numbers: - `gzip -5 style.min.css` : 1,134 bytes - `brotli -5 style.min.css` : 996 bytes - `zstd -8 style.min.css` : 1,142 bytes The original `style.css` compressed at the same rates is still larger: - `gzip -5 style.css` : 3,727 bytes - `brotli -5 style.css` : 3,426 bytes - `zstd -8 style.css` : 3,701 bytes This is an improvement across the board, and doesn't change the ability to run the theme without having to touch a build system.
This is possible now that WordPress#33 has been merged
The minified stylesheet can't follow the WordPress CSS Coding Standards, so `npm run lint:css` would fail on it. The pre-commit hook passes staged files to Stylelint by name, so it also needs --allow-empty-input for a commit that only rebuilds style.min.css. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
style.css changed on trunk since style.min.css was built, including the palette rename in WordPress#179, so the old minified file pointed at color slugs that no longer exist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AGENTS.md still said there is no build step, and that style.css loads on the front end. CONTRIBUTING.md called style.css the only stylesheet, which stopped being true when assets/css/editor-style.css landed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
style.min.css is committed, so nothing stopped a pull request from changing style.css without rebuilding it. The CSS job now rebuilds it and fails if the result differs from the committed copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributors no longer need to remember npm run build when they change style.css, and the CI check should rarely fail. Stylelint isn't repeated in the new task because the *.css task already runs it on style.css. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Trunk changed style.css in WordPress#180 and WordPress#198 after this branch was last rebuilt, so the CI check failed on the merge with trunk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3731d1e to
e85c5bd
Compare
mikachan
left a comment
There was a problem hiding this comment.
Thanks for the changes! I think this is ready to bring in.
**Depends on WordPress#61, which must be merged first.** The added line uses the `$src` variable from WordPress#61, so this does not work on its own. Adds `path` data to the `ipsum-style` handle so WordPress inlines the theme stylesheet instead of loading it as a render-blocking request. Twenty Twenty-Five does the same - https://themes.trac.wordpress.org/browser/twentytwentyfive/1.5/functions.php#L40 With WordPress#61 merged we get `style.min.css` in production and `style.css` when `SCRIPT_DEBUG` is on. One less render blocking request, and the minified version is already pretty small. If we get similar compression results to the stand alone minified version then we are looking at ~1.1KB increase. A very modest increase for the potential improvement.
When `SCRIPT_DEBUG` is off, Ipsum now enqueues `style.min.css`, which is about a third of the size of `style.css`. It falls back to `style.css` when the minified file is missing or older, so edits made in the Theme File Editor keep working. The minified file isn't committed: core's build makes it, as it does for Twenty Twenty-Two and Twenty Twenty-Five. Synced from WordPress/ipsum#61. See #66631. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
**Depends on WordPress#61, which must be merged first.** The added line uses the `$src` variable from WordPress#61, so this does not work on its own. Adds `path` data to the `ipsum-style` handle so WordPress inlines the theme stylesheet instead of loading it as a render-blocking request. Twenty Twenty-Five does the same - https://themes.trac.wordpress.org/browser/twentytwentyfive/1.5/functions.php#L40 With WordPress#61 merged we get `style.min.css` in production and `style.css` when `SCRIPT_DEBUG` is on. One less render blocking request, and the minified version is already pretty small. If we get similar compression results to the stand alone minified version then we are looking at ~1.1KB increase. A very modest increase for the potential improvement.
* Inline the theme stylesheet **Depends on #61, which must be merged first.** The added line uses the `$src` variable from #61, so this does not work on its own. Adds `path` data to the `ipsum-style` handle so WordPress inlines the theme stylesheet instead of loading it as a render-blocking request. Twenty Twenty-Five does the same - https://themes.trac.wordpress.org/browser/twentytwentyfive/1.5/functions.php#L40 With #61 merged we get `style.min.css` in production and `style.css` when `SCRIPT_DEBUG` is on. One less render blocking request, and the minified version is already pretty small. If we get similar compression results to the stand alone minified version then we are looking at ~1.1KB increase. A very modest increase for the potential improvement. * Say in the docs that the theme stylesheet is inlined The front end no longer requests style.css or style.min.css, so there's no link tag or request for an agent to look for or intercept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: MaggieCabrera <maggie.cabrera@automattic.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: josephscott <josephscott@git.wordpress.org> Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org>
This updates Ipsum from `17a7ada71378a21c36670d67725b3ca632845a9f` to `bc2e5af700e28980f251d97f58cf80c72ee50a13` on its `trunk` branch. A full list of changes included in this commit can be found on GitHub: WordPress/ipsum@17a7ada...bc2e5af - theme.json: Give negative outline offset for Button's focus styles (WordPress/ipsum#187) - Fix view transitions ignoring prefers-reduced-motion (WordPress/ipsum#198) - Register the pattern utility classes as block styles (WordPress/ipsum#180) - Fix the PHPStan level 10 errors that core reports (WordPress/ipsum#171) - Provide style.min.css for production (WordPress/ipsum#61) - Use the border radius shorthand in the patterns (WordPress/ipsum#206) - Describe every pattern and offer the format patterns as starter patterns (WordPress/ipsum#181) - Move what theme.json can express out of the block css strings (WordPress/ipsum#185) - Clean up editor-only attributes and serialization in the patterns (WordPress/ipsum#204) - Add DESIGN.md with the theme's design model (WordPress/ipsum#186) - Inline the theme stylesheet (WordPress/ipsum#63) - Design guide: Return all theme patterns after the registry has read them (WordPress/ipsum#192) This commit also includes changes that only exist in core: - Ipsum is added to the `cssmin:themes` Grunt task, so the build makes the `style.min.css` that the theme now enqueues. The built file is ignored. - The theme's `node_modules` directory is ignored, and left out of core's build. - The theme gets its own stylesheet build process, with `build` and `watch` commands that minify `style.css` into `style.min.css`, set up through a new `package.json`, `package-lock.json` and `.nvmrc`. - A new `contributing.txt` documents the build process and the `test-and-zip-default-themes` workflow now tests and runs that build for Ipsum. - Regression tests for the design guide ability are added in core, with a child theme fixture, because Ipsum's repository has no PHPUnit setup. Follow-up to r60934, r64677, r64678, r64679, r65224. Props yashjawale, shailu25, onemaggie, westonruter, josephscott, juanfra, mehtadev, mikachan, ravipatel, wildworks, courane01, poena, gziolo. Fixes #66631. See #66352. git-svn-id: https://develop.svn.wordpress.org/trunk@65366 602fd350-edb4-49c9-b593-d223f7449a82
This updates Ipsum from `17a7ada71378a21c36670d67725b3ca632845a9f` to `bc2e5af700e28980f251d97f58cf80c72ee50a13` on its `trunk` branch. A full list of changes included in this commit can be found on GitHub: WordPress/ipsum@17a7ada...bc2e5af - theme.json: Give negative outline offset for Button's focus styles (WordPress/ipsum#187) - Fix view transitions ignoring prefers-reduced-motion (WordPress/ipsum#198) - Register the pattern utility classes as block styles (WordPress/ipsum#180) - Fix the PHPStan level 10 errors that core reports (WordPress/ipsum#171) - Provide style.min.css for production (WordPress/ipsum#61) - Use the border radius shorthand in the patterns (WordPress/ipsum#206) - Describe every pattern and offer the format patterns as starter patterns (WordPress/ipsum#181) - Move what theme.json can express out of the block css strings (WordPress/ipsum#185) - Clean up editor-only attributes and serialization in the patterns (WordPress/ipsum#204) - Add DESIGN.md with the theme's design model (WordPress/ipsum#186) - Inline the theme stylesheet (WordPress/ipsum#63) - Design guide: Return all theme patterns after the registry has read them (WordPress/ipsum#192) This commit also includes changes that only exist in core: - Ipsum is added to the `cssmin:themes` Grunt task, so the build makes the `style.min.css` that the theme now enqueues. The built file is ignored. - The theme's `node_modules` directory is ignored, and left out of core's build. - The theme gets its own stylesheet build process, with `build` and `watch` commands that minify `style.css` into `style.min.css`, set up through a new `package.json`, `package-lock.json` and `.nvmrc`. - A new `contributing.txt` documents the build process and the `test-and-zip-default-themes` workflow now tests and runs that build for Ipsum. - Regression tests for the design guide ability are added in core, with a child theme fixture, because Ipsum's repository has no PHPUnit setup. Follow-up to r60934, r64677, r64678, r64679, r65224. Props yashjawale, shailu25, onemaggie, westonruter, josephscott, juanfra, mehtadev, mikachan, ravipatel, wildworks, courane01, poena, gziolo. Fixes #66631. See #66352. Built from https://develop.svn.wordpress.org/trunk@65366 git-svn-id: http://core.svn.wordpress.org/trunk@64505 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This updates Ipsum from `17a7ada71378a21c36670d67725b3ca632845a9f` to `bc2e5af700e28980f251d97f58cf80c72ee50a13` on its `trunk` branch. A full list of changes included in this commit can be found on GitHub: WordPress/ipsum@17a7ada...bc2e5af - theme.json: Give negative outline offset for Button's focus styles (WordPress/ipsum#187) - Fix view transitions ignoring prefers-reduced-motion (WordPress/ipsum#198) - Register the pattern utility classes as block styles (WordPress/ipsum#180) - Fix the PHPStan level 10 errors that core reports (WordPress/ipsum#171) - Provide style.min.css for production (WordPress/ipsum#61) - Use the border radius shorthand in the patterns (WordPress/ipsum#206) - Describe every pattern and offer the format patterns as starter patterns (WordPress/ipsum#181) - Move what theme.json can express out of the block css strings (WordPress/ipsum#185) - Clean up editor-only attributes and serialization in the patterns (WordPress/ipsum#204) - Add DESIGN.md with the theme's design model (WordPress/ipsum#186) - Inline the theme stylesheet (WordPress/ipsum#63) - Design guide: Return all theme patterns after the registry has read them (WordPress/ipsum#192) This commit also includes changes that only exist in core: - Ipsum is added to the `cssmin:themes` Grunt task, so the build makes the `style.min.css` that the theme now enqueues. The built file is ignored. - The theme's `node_modules` directory is ignored, and left out of core's build. - The theme gets its own stylesheet build process, with `build` and `watch` commands that minify `style.css` into `style.min.css`, set up through a new `package.json`, `package-lock.json` and `.nvmrc`. - A new `contributing.txt` documents the build process and the `test-and-zip-default-themes` workflow now tests and runs that build for Ipsum. - Regression tests for the design guide ability are added in core, with a child theme fixture, because Ipsum's repository has no PHPUnit setup. Follow-up to r60934, r64677, r64678, r64679, r65224. Props yashjawale, shailu25, onemaggie, westonruter, josephscott, juanfra, mehtadev, mikachan, ravipatel, wildworks, courane01, poena, gziolo. Fixes #66631. See #66352. git-svn-id: https://develop.svn.wordpress.org/trunk@65366 602fd350-edb4-49c9-b593-d223f7449a82
Using the same pattern as the TT5 theme - https://themes.trac.wordpress.org/browser/twentytwentyfive/1.5/package.json - this change adds a
style.min.cssand the tooling around it to build it.The
style.cssfile would still be used any time thatSCRIPT_DEBUGis true - which is the case for thewp-envsetup used by Ipsum. Production setups would get the benefit of using the smallerstyle.min.cssfile.For sizes,
style.min.csscomes in at 3,354 bytes. Down from the 9,380 bytes ofstyle.css. Here are a few quick compression numbers:gzip -5 style.min.css: 1,134 bytesbrotli -5 style.min.css: 996 byteszstd -8 style.min.css: 1,142 bytesThe original
style.csscompressed at the same rates is still larger:gzip -5 style.css: 3,727 bytesbrotli -5 style.css: 3,426 byteszstd -8 style.css: 3,701 bytesThis is an improvement across the board, and doesn't change the ability to run the theme without having to touch a build system.
AI assistance: Yes
Tool(s): Claude
Model(s): Fable 5.1
Used for: Tightly guided, directed, and reviewed. It was all based on the existing pattern for this that was used in the TT5 theme.