Defer icons to icons stack to reduce DOM count #191
Merged
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.
This pr allows you to defer the content of SVG elements to drastically reduce DOM element counts for complex icons which are used often on a page.
It's an easier to use alternative to using spritesheets to tackle #185
The way it works is simply by adding an attribute of defer to the icon e.g.
And loading the stack at the bottom of your layout
As an example here we're using the larger SVGs of the heroicon pack multiple times
The transparent cubes are 1K and the dollar sign is 880B
Loading these in every time we use the icon on a page would result in nearly 6K added to the page which is a lot for a couple of icons.
A category page with products using that icon for it's price might add 24K to the document for 24 paginated products.
Defering these icons will leave that at 1K and only take a couple of bytes for using the icons
In the HTML this will now result in
This will not break any exising usages of the icon pack since it requires you to add the
defer
attribute manually or add it underattributes
inconfig/blade-icons.php