[css4-images] Add format() hints to image()

The problem: image('whatever.webp', 'whatever.png')

If the browser doesn't support webp it will still download 'whatever.webp'
and attempt a decode before it'll fallback to the png. It could exit early
when it gets the content-type header, but that's still more network
activity than ideal.

Solution: Introduce format(), from @font-face

https://gist.github.com/jakearchibald/2f6baeeefd0eee59d9ec

The browser wouldn't bother with the webp if it doesn't understand it. Like
fonts, format isn't limited to mime types, allowing for
format('webp-progressive'), if webp ever gets a progressive format.

The formats would be defined by the spec, as with fonts.

Alternative solution: format fragment

https://gist.github.com/jakearchibald/2f6baeeefd0eee59d9ec#file-gistfile1-css-L12

We already use the fragment for media fragments, could use it for format
too. However, this creates repetition in image-set. Meh.

Another alternative: Look at the 'extension'

Could look at the suffix of the url. This has repetition in image-set as
above, but also feels clunky, especially for format sub-types, eg
whatever.webp-progressive.

Received on Thursday, 14 February 2013 10:40:49 UTC