W
W
weranda2018-01-29 18:44:38
Browsers
weranda, 2018-01-29 18:44:38

Does it make sense to add the font to local storage?

Greetings
There are two fonts in base64 and there are two options for adding them:

  1. When the site is loaded for the first time, we add the font to local storage via JS or PHP. Then we pull it when rendering other pages from local storage.
  2. We don’t worry about local storage at all and add a style file with a base64 font to HEAD and when loading other pages it will already be taken from the cache

That in the first, that in the second case the piece of the code, two requests all the same will be pulled.
What is it ..., what is it ... (© Bredor)
What are the advantages and disadvantages of these options and what do you recommend?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
iBird Rose, 2018-01-29
@weranda

The fact of the matter is that there is no point in the first option, if with option 2, the user will have it in the browser cache.
There is 3 option - use fonts from https://fonts.google.com/
The advantage of this method compared to the second one is that the font may be in the user's cache even before visiting your site. Because on another site where the user was, the same font was already loaded from Google Fonts.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question