Git Product home page Git Product logo

optimizedwebfontloading's People

Contributors

bdadam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

optimizedwebfontloading's Issues

Update to proper MIME type

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.

Release to npm

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.

Only apply font if it's already in localStorage

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.