bdadam / optimizedwebfontloading Goto Github PK
View Code? Open in Web Editor NEWHaving optimal pagespeed but still loading webfonts
Home Page: http://bdadam.com/blog/loading-webfonts-with-high-performance.html
Having optimal pagespeed but still loading webfonts
Home Page: http://bdadam.com/blog/loading-webfonts-with-high-performance.html
Great code, playing with it now in WordPress. After setting it up I noticed error like the following in the Chrome dev tools console
Resource interpreted as Font but transferred with MIME type application/x-font-woff2
Looking through the JS I noticed this
var localStoragePrefix = 'x-font-' + fontName;
Isn't the official MIME type for this without the x- part? Changing this made the errors go away.
I am using this script on Sass Guidelines so I was wondering if you would consider releasing it to npm so that I can handle this as an actual dependency? Right now I had to copy your script in my assets folder, which is far from ideal.
If you accept to do so, it would be best to remove the supportsWoff2
function from your code and use woff2-feature-test from Filament Group (which you do already) as an actual dependency.
I am well willing to assist you in that if you feel the need.
Cheers.
First of all, thanks for your research and the script - using it on some sites and it works great so far.
On a recent project I did a lot of testing and especially on low bandwdith FOUT is quite annoying (at least for me). That's why I only apply the font if the user already has been on the page and the font is stored in localStorage.
I basically changed
loSto[localStorageCssKey] = styleElement.textContent = request.responseText;
to
loSto[localStorageCssKey] = request.responseText;
So maybe it's a good idea to add an option to apply the fonts only on second page load?
What do you think?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.