- From: John Daggett <jdaggett@mozilla.com>
- Date: Tue, 11 Nov 2014 18:15:28 -0800 (PST)
- To: www-style list <www-style@w3.org>
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 document. > * 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. Cheers, John Daggett Mozilla Japan
Received on Wednesday, 12 November 2014 02:15:56 UTC