Skip to content
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

Merged
merged 3 commits into from
Sep 2, 2020

Conversation

joelhawksley
Copy link
Contributor

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

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>
@vercel
Copy link

vercel bot commented Aug 27, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/primer/octicons/jmhxvol4m
✅ Preview: https://octicons-git-octicons-caching.primer.vercel.app

[update for 7a0eaf9 failed]

@vercel vercel bot temporarily deployed to Preview August 27, 2020 19:42 Inactive
Copy link
Member

@jonrohan jonrohan left a 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)
Copy link
Member

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?

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants