-
Notifications
You must be signed in to change notification settings - Fork 827
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
Cache Octicon SVGs for same icon/options combination #491
Conversation
This PR upstreams an optimization we've been using internally to speed up rendering the same octicon multiple times. Rendering octicons can be expensive when done often on a page. For example, rendering the same "check" octicon in a large list of items can add up on a page, so often we'll render it once and then pass in the rendered HTML string into the list items. Co-authored-by: Simon Taranto <srt32@github.com>
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/primer/octicons/jmhxvol4m [update for 7a0eaf9 failed] |
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.
Code added looks good, had a question on what your thoughts are about adding a raise. But not a blocker.
if octicons_helper_cache[cache_key] | ||
octicons_helper_cache[cache_key] | ||
else | ||
icon = Octicons::Octicon.new(symbol, options) |
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.
Do you think we should include any of the raise conditions here when the symbol doesn't exist?
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.
@jonrohan Good idea! I think we should look into it in another PR.
This PR upstreams an optimization we've been using
internally to speed up rendering the same octicon
multiple times.
Rendering octicons can be expensive when done often on a page. For
example, rendering the same "check" octicon in a large list of items can
add up on a page, so often we'll render it once and then pass in the
rendered HTML string into the list items.
Co-authored-by: Simon Taranto - @srt32