Fix issues with how assets are enqueued on the new SVG block #112
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.
Description of the Change
A new SVG block was added in PR #80, which went out in the 2.1.0 release. We've gotten a handful of reports around how assets are being loaded for this block, most notably:
This PR fixes all of those issues by removing the JS file from being loaded at all and moving the CSS file from a typical enqueue to being loaded as part of the
block.json
. This ensures the CSS is only loaded on pages that are using the block and it loads the CSS inline instead of loading an extra stylesheet.Also fix an incorrect use of
add_filter
to beadd_action
Closes #109
How to test the Change
On the current released version (2.1.0) view any page on your site and note that two block related files (a CSS and JS file) are being loaded.
Checkout this branch and note those files are no longer loaded at all, even if a page has an SVG block. Verify the block itself still works and renders as expected.
Changelog Entry
Credits
Props @dkotter, @freinbichler, @IanDelMar, @ocean90
Checklist: