-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add icon sprite via local storage #6243
Add icon sprite via local storage #6243
Conversation
Manage this branch in SquashTest this branch here: https://allcapsicon-sprite-local-stora-pzwaj.squash.io |
f7f1e58
to
2972b8d
Compare
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.
Coen!! This is brilliant! I'm so glad you found this technique. It's working great for me (tested in Firefox, Chrome, Safari, and IE11). I would like @thibaudcolas to review the JS specifically, but I do have one small question about it.
267b44c
to
5b5cb2a
Compare
5b5cb2a
to
709a7d9
Compare
All feedback is applied. I moved the script into the page body. This way it is executed on load. All icons are directly available for paint. What do we do with the catched error? Not displaying icons is an obvious fail. I propose we don't handle the error at all. |
709a7d9
to
f8182b6
Compare
I’ll try and review this over the next two weeks. @allcaps is there anything in particular you know might not be ready to go? |
Ready! |
f8182b6
to
b41707b
Compare
I rebased and simplified the code a bit. I dropped the template tag. Now the view itself is cached. This is less code and easier to understand. |
Ready again :D |
23e6708
to
e6b099d
Compare
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.
@allcaps this is looking really good! The icons are missing for a small amount of time on the first page load, but this is similar to an icon font’s performance, and for subsequent page loads the SVG icons seem to load faster than the icon fonts’.
I’ve suggested a few more changes but they are very minor.
For future reference, I tried to improve the first load performance with <link rel="preload" href="{% url 'wagtailadmin_sprite' %}" as="fetch">
towards the top of skeleton.html
. This works as expected, however it has the drawback of always being there, even after the first load, so feels very wasteful for a one-off performance gain. I don’t think this is worthwhile.
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.
Wooo!
18012ad
to
2b3de87
Compare
Rebased, merged, and ready for release in 2.11! Thank you @allcaps, it looks like a lot of thought went into this, and it’s working perfectly as far as I can tell. I haven’t done any thorough benchmarking but this looks like it will improve first page load performance to be as good as the best external sprites implementation, while subsequent page loads will be as fast as the best inline sprites implementations – all the while preserving compatibility with IE11. Cool stuff :) |
This PR stores the sprite in local storage and injects it into the page body.
A previous attempt has an external sprite with IE11 polyfill. #6231
Unfortunately, it leads to flashing icons in Firefox. :/
This PR:
Checks: