documentcloud / jammit

Industrial Strength Asset Packaging for Rails
http://documentcloud.github.com/jammit/
MIT License
1.16k stars 197 forks source link

Use (more) authoritative MIME types so that embedded .woff and .ttf don't raise warnings in WebKit Web Inspector #220

Closed fancyremarker closed 12 years ago

fancyremarker commented 12 years ago

In recent versions of WebKit, .woff fonts transferred with type font/woff (and .ttf fonts transferred with type font/truetype) raise warnings like the following in Web Inspector: https://img.skitch.com/20120222-rcfx7t37cew21119cjq6mqjkqs.png

This "bug" is documented in Chromium's issue tracker: http://code.google.com/p/chromium/issues/detail?id=70283

But per the WOFF file format, application/x-font-woff is the appropriate type here. (Same for application/x-font-ttf; in general, font/* is not a valid MIME type, but I haven't touched font/opentype because WebKit treats that as a valid MIME type for some reason.

jashkenas commented 12 years ago

Ugh. I loathe mime-type wankery, especially after the powers that be have said to stop using x- prefixes.

However, after looking at that WebKit ticket, things look very unresolved. Are you sure this won't just consign us to warnings in other browsers down the road?

dblock commented 12 years ago

More fun here.

Either way, whichever mime type you choose now, it's going to be incorrect because there's no "correct" way. I would give a +1 for this pull though, especially for the WOFF format, font/woff is an imaginary type that has no chance of becoming the standard.

Do we need a way to specify the mime type mapping in Jammit? Maybe use http://rubygems.org/gems/mime-types?

fancyremarker commented 12 years ago

I'm definitely not sure that this will be impervious to future browser warnings; I'm just making a best guess about the direction browser MIME type standards are heading, but it's still pretty unresolved, as you say.

Maybe allowing custom user-defined MIME type mappings is the way to go? That seems a bit too configuration-heavy though.

ScotterC commented 12 years ago

Anyone know a good way to silence those warnings in the meantime?

fancyremarker commented 12 years ago

@ScotterC: this small commit should silence the warnings. It's not guaranteed to work forever, since the standards issue hasn't been entirely resolved, but it works now.

ScotterC commented 12 years ago

@jashkenas Thanks for merging.