W3C home > Mailing lists > Public > www-style@w3.org > November 2014

Re: [css-fonts] font prefetch hints

From: John Daggett <jdaggett@mozilla.com>
Date: Tue, 11 Nov 2014 18:15:28 -0800 (PST)
To: www-style list <www-style@w3.org>
Message-ID: <677582465.11441811.1415758528384.JavaMail.zimbra@mozilla.com>

Hi Yoav,

> Regarding the opt-in for preloading purposes, I believe (but have
> not proved yet) that it may not be necessary, and that CSS based
> resources can be preloaded without it, at least for the majority
> of cases.
> The HTML preloader can keep track of tag names, IDs and class
> names it encounters (and whether they contained text). A CSS
> preloader can then scan CSS tokens, find resources, and assuming
> they have a simple selector, see if they should be downloaded and
> if so, kick off that download.

The key point is that font resources defined by @font-face rules are
"load on demand". So if a document never *uses* a font family, not
font resource loading will occur.

> The tricky parts would be:
> * CSS rules that get overridden further down the line.  I need to gather
> data about how often that happens, since that may trigger needless
> downloads.

You're thinking of *style* rules. An @font-face rule can't be
overridden, except indirectly by defining another rule that
effectively masks an earlier one.

> * Complex selectors that trigger resource download - Keeping track of
> complex relationships won't be feasible, so such resources won't be
> preloaded. Again, need data.

A preload hint on an @font-face rule would indicate that a font
should be loaded independent of whether it's used in the current

> * Unicode ranges for text - They would be harder to track. Maybe we can
> flag tokens with popular ranges, but it's trickier.

The 'unicode-range' descriptor defines which face with a font family
is *used* and hence, which font resource would be loaded. With a
preload hint, the loading would occur but the 'unicode-range' value
would still dictate when it's used.

The key problem a preload hint would solve is that the decision
about whether to use a font or not happens fairly late in the page
loading process. The hint would simply short circuit the "is this
font used?" process and add it to the load queue.


John Daggett
Mozilla Japan
Received on Wednesday, 12 November 2014 02:15:56 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:48 UTC