This repository has been archived by the owner on Jun 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Register Font Awesome stylesheet once and print only when needed #294
Merged
mindctrl
merged 2 commits into
studiopress:develop
from
westonruter:add/conditionally-print-fontawesome-just-in-time
Jan 14, 2020
Merged
Register Font Awesome stylesheet once and print only when needed #294
mindctrl
merged 2 commits into
studiopress:develop
from
westonruter:add/conditionally-print-fontawesome-just-in-time
Jan 14, 2020
Conversation
This file contains 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
This was referenced Jan 13, 2020
nickcernis
approved these changes
Jan 14, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed that:
- Font Awesome CSS does not load if no icon blocks present.
- CSS loads if a block such as AB Sharing is present.
link
element only appears once for multiple AB Sharing blocks.- Blocks that list posts containing AB Sharing blocks, such as the Post Grid, don't appear to be negatively affected.
Thank you @westonruter! Works great. Thanks for testing @nickcernis! |
4 tasks
mindctrl
added a commit
that referenced
this pull request
Feb 10, 2020
mindctrl
added a commit
that referenced
this pull request
Feb 17, 2020
…e' of https://github.com/westonruter/atomic-blocks into westonruter-add/conditionally-print-fontawesome-just-in-time" This reverts commit 0ab51fc, reversing changes made to b336ce3. Issue #127. PR #294.
FYI: Gutenberg core is now moving in this direction. See WordPress/gutenberg#21838 and its PR WordPress/gutenberg#22754. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary of change:
The Font Awesome stylesheet is large and if it is not needed on the page then it wastes bandwidth and browser CPU cycles. It also contributes negatively to the overall CSS budget of 50KB on AMP pages (see ampproject/amp-wp#4095). Therefore, the stylesheet should only be printed when it is actually needed by a block.
This has the added benefit of preventing the Font Awesome stylesheet from blocking the rendering content that appears before the first block that makes use of it.
This PR also centralizes the registration of the Font Awesome stylesheet in the
wp_default_styles
action, eliminating duplicated references to the stylesheet path.Have the changes in this PR been added to the documentation for this project?
Does not apply
How to test:
Fixes: #127
Suggested Changelog Entry: