Чтобы не мелькали шрифты в Хроме

Описание задачи:

На страницах используются значки-иконки из Font Awesome. После того, как был подключен Cloudflare CDN, у локальных ресурсов вроде fontawesome.woff2 появились хедеры вроде vary:Accept-Encoding.

Вероятно, именно это привело к тому, что ресурсы fontawesome в Chrome v56, v57 (latest) перестали загружаться (from memory cache), а стали (from disk cache).

А это в свою очередь привело к тому, что иконки при переходах между страницами стали мерцать, сначала они не показываются. Их плейсхолдеры имеют не идеальную ширину, поэтому контент страницы при загрузке начал скакать.

Нужно, чтобы контент страницы не скакал, чтобы иконки показывались сразу. Чтобы было ощущение one-page-app, будто меняется только контент, но не меню и хедеры вокруг.

Причины:

В браузерах вроде FF или IE проблемы мерцания не наблюдается. Только в браузерах на движке хрома.

Хром обрабатывает директивы @font-face следующим образом: хотя содержимое и прочитано, указанные файлы не будут загружены вплоть до момента, пока данный шрифт не будет впервые использован. В моём случае, иконки font-awesome добавлялись только лишь через css-псевдоклассы :before и :after, вероятно поэтому браузер уже отрисовывал содержимое страницы, но шрифт, даже из дискового кеша, не успевал брать. Лишь из мемори кеша шрифт успевал браться, но этот тип кеша поломали заголовки cloudflare.

Шрифт «нигде не используется», браузер отрисовывает содержимое страницы, в процессе применения css обнаруживает, что шрифт всё-таки используется, но уже поздно. Происходит FOUC.

Не важно, что и шрифт, и все стили объявлены в <head>. Хром всё равно будет мелькать шрифтами.

Решение:

Решением могли бы быть:
а) всё-таки добиться опять попадания файла шрифта в chrome memory cache.
б) использовать элемент из этого шрифта нативно в теле страницы, а не через псевдоклассы.

Но мне это не подошло. Решение следующее:

preload

Приказываем браузеру пред-загрузить данный файл в память, вне зависимости от того, что он думает про свою оптимизацию.

Теперь файл woff2 подгружается всегда, прежде чем начнётся отрисовка документа. Теперь даже если отключен кеш, иконки мелькать не будут, контент прыгать не будет.

Всё работает. Ура!

Обсуждение

avatar

sprunki game
2025.12.09 13:11

Sprunki Incredibox truly elevates the music creation experience with its fresh beats and intuitive design. As a poker player, I appreciate the strategic depth and creativity it brings to the table. Check it out at Sprunki Incredibox.

og777app
2025.12.12 13:19

I’ve played on OG777app for a while now. It’s convenient since it’s on my phone. Good when you’re on the go and bored. Give it a shot: og777app

j10gamedownload
2025.12.28 00:04

Alright, so I stumbled upon j10gamedownload the other day. Looks like they got a bunch of game downloads. Gonna try one out later, hopefully no dodgy stuff! See for yourself j10gamedownload!

aaajili36
2026.01.03 12:36

Aaajili36? Heard some good things about their promotions. I haven’t personally tried it, but a buddy of mine swears by it. Maybe worth checking out the bonuses. aaajili36

jl16
2026.01.06 15:20

It’s fascinating how easily accessible online gaming has become, especially in places like the Philippines. The emphasis on secure platforms like jl16 slot & local payment options is smart-trust is huge when it comes to digital entertainment! It’s good to see responsible gaming gaining traction too.

mu88ai
2026.01.07 04:31

Alright, champs! Checked out mu88ai. Decent selection of games and the site’s fairly straightforward. Could be worth a look if you’re bored. Check it out here: mu88ai

barganhar plataforma
2026.01.14 16:25

Barganhar plataforma, huh? Sounds Portuguese! Let’s see if I can snag a good deal here. Time to test my luck! barganhar plataforma

881jili
2026.01.24 22:42
2222ph
2026.01.24 22:54
luxebet88
2026.01.24 23:07
80jili
2026.01.25 08:51
tayabet
2026.01.26 16:01

Tayabet: The Philippines’ Premier GCash Online Casino for Best Slots and Gambling. visit: tayabet

45678betvn
2026.01.29 01:33

Yo, has anyone else been checking out 45678betvn? It’s got that Vietnamese feel to it, which is cool. The interface isn’t too shabby either. Give it a look if you’re looking to try something different. Here’s the link: 45678betvn

aa8881
2026.01.29 01:34

Just stumbled across aa8881 and decided to give it a whirl. Gotta say, the layout is pretty appealing. Let’s see how it goes! Check it out aa8881

blogmcgames
2026.01.29 01:34

Looking for some tips and tricks on some new games. Stumbled across blogmcgames.com. Hopefully, it’s got some strategy guides and insider info! Take a peek: blogmcgames

nustar online gcash login

Pwede palang mag-login sa Nustar online using GCash? That’s awesome! So much easier to deposit and play. Galing talaga! Para sa atin to. nustar online gcash login

bong da net
2026.02.02 12:56

For all things ‘bong da net,’ this website is a winner. Simple layout, comprehensive content. I’m hooked! See for yourself: bong da net

slots vip
2026.02.02 12:57

Been trying out Slots VIP and am enjoying the selection of the games. Give it a look see slots vip

wpDiscuz