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

Load custom fonts without webfont.js #2944

Merged

Conversation

jahvi
Copy link
Contributor

@jahvi jahvi commented May 23, 2019

Related issues

N/A

Short description and why it's useful

Right now custom google fonts (Playfair Display, Robot and Material Icons) are loaded using webfont.js which is useful because it helps load custom fonts asynchronously and prevent FOUC however it comes at a cost.

I noticed this also run some expensive tasks in the browser that triggers "Style Recalculations" which can be very costly for the browser and one the things Google recommends minimising.

Purple spikes = style recalculations
Screenshot 2019-05-23 at 9 27 49 pm
Performance trace (before)

I replaced this to use a css @import which is not the best but I believe with the addition of font-display: swap it can help cover the benefits of webfont.js without the processing drawbacks (and also reduces the JS used by ~3%)

Fewer purple spikes
Screenshot 2019-05-23 at 9 34 54 pm
Performance trace (after)

It's hard for me to measure the performance benefits with my local server but I noticed around ~10% increase in FP, FCP and FMP. We can include the @font-face declarations directly which should help with latency while getting the fonts as well but that's open to discussion.

Screenshots of visual changes before/after (if there are any)

See above

Which environment this relates to

Check your case. In case of any doubts please read about Release Cycle

  • Test version (https://test.storefrontcloud.io) - this is a new feature or improvement for Vue Storefront. I've created branch from develop branch and want to merge it back to develop
  • RC version (https://next.storefrontcloud.io) - this is a stabilisation fix for Release Candidate of Vue Storefront. I've created branch from release branch and want to merge it back to release
  • Stable version (https://demo.storefrontcloud.io) - this is an important fix for current stable version. I've created branch from hotfix or master branch and want to merge it back to hotfix

Upgrade Notes and Changelog

  • No upgrade steps required (100% backward compatibility and no breaking changes)
  • I've updated the Upgrade notes and Changelog on how to port existing VS sites with this new feature

IMPORTANT NOTICE - Remember to update CHANGELOG.md with description of your change

Contribution and currently important rules acceptance

@patzick patzick added this to the 1.10.0-rc.1 milestone May 27, 2019
@patzick patzick changed the base branch from develop to develop_merge_bulk May 27, 2019 10:57
@patzick patzick added the QA - Ready for tests This is notification for testers, that improvement is ready to be tested and verified. label May 27, 2019
@patzick patzick merged commit 58317f9 into vuestorefront:develop_merge_bulk May 27, 2019
@patzick
Copy link
Collaborator

patzick commented May 27, 2019

Thanks @jahvi !

QA team note - tests should check if there are some problems with font loads

@alinadivante alinadivante added QA approved after merge Testers will add this label after positive check on merged changes and removed QA - Ready for tests This is notification for testers, that improvement is ready to be tested and verified. labels May 28, 2019
@patzick patzick added the vs-hackathon Tasks for the Hackathon label May 28, 2019
@MariaKern
Copy link
Contributor

Related to #2893

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
QA approved after merge Testers will add this label after positive check on merged changes vs-hackathon Tasks for the Hackathon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants