Repository navigation
Request style.css only when a child theme is active - #54
Closed
khan-rafin-ahmed wants to merge 1 commit into
Closed
khan-rafin-ahmed wants to merge 1 commit into
khan-rafin-ahmed wants to merge 1 commit into
Conversation
The parent style.css only carries the theme header, so enqueueing it added an empty render-blocking stylesheet request to every page. Keep the flexia-style handle (so inline styles and dependants keep working) but give it a source only when a child theme's stylesheet needs loading. Closes 53 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
Landed on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #53
Problem
Without a child theme,
flexia_styles()enqueued the parentstyle.css, which holds only the theme header comment and no rules. The result was an empty render-blocking stylesheet request on every front-end page.Change
flexia-styleis still enqueued with the same dependencies and version. Its source is:get_stylesheet_uri()whenis_child_theme(), so the child stylesheet loads exactly as before;falseotherwise. WordPress then prints any inline CSS attached to the handle, without a<link>.Tests
tests/wordpress.phpgains three assertions:wp_add_inline_style( 'flexia-style', … )still prints, and no<link>tag is emitted.get_stylesheet_uri().Run locally:
php -lon changed filespython3 tools/check-theme.py(832 block declarations, 0 errors)python3 -m unittest discover -s tests -p 'test_*.py'(4 OK)tests/wordpress.phpruns in the disposable-WordPress CI job.🤖 Generated with Claude Code