Google Chrome Developers says:
The new WOFF 2.0 Web Font compression format offers a 30% average gain over WOFF 1.0 (up to 50%+ in some cases). WOFF 2.0 is available since Chrome 36 and Opera 23.
Some examples of file size differences: WOFF vs. WOFF2
@font-face {
font-family: MyFont;
src:
url('myfont.woff2') format('woff2'),
url('myfont.woff') format('woff');
}
Of course you can use WOFF2 as a Base64 encoded string:
@font-face {
font-family: MyFont;
src:
url('data:font/woff2;base64,...') format('woff2'),
url('data:font/woff;base64,...') format('woff');
}
- Please no serverside GZIP compression for WOFF files, because WOFF already contains compressed data.
- Think about the correct mime type for WOFF 2.0 files (Google uses font/woff2. W3C recommends font/woff2 too):
types {
font/woff2 woff2;
}
AddType font/woff2 .woff2
- Google Chrome 36
- Opera 23
- Firefox 39
- Opera 23
- Edge 14
- Safari 12
What's missing from this gist is a feature test. We are using this one to detect WOFF2 supports https://github.com/filamentgroup/woff2-feature-test/blob/master/woff2.js
And serve WOFF or WOFF2 base64 encoded in a JSON file depending on the outcome. Basically like how The Guardian does it. This was an early prototype mimicking that behavior (without WOFF2 detection) http://codepen.io/CrocoDillon/pen/dkcbs , enjoy! :)