A different kind of HTML5 shim

As I’m sure many of you are aware, in order to get older versions of Internet Explorer to recognise and apply styles to the new elements defined in HTML5, a JavaScript file known as a “shiv” or “shim” needs to be used.

The standard HTML5 shiv that tends to be used is html5shiv.js, by Alexander Farka and Remy Sharp (you can also read Paul Irish’s The Story of the HTML5 shiv for further information.)

Today however I came across another type of HTML5 shim that uses Internet Explorer’s HTML Components, or HTC, files. A HTC file is defined as:

… an HTML file that contains script and a set of HTC-specific elements that define the component.

This particular shim was written by Christopher Jeffrey, and he posted about it a year ago. I can’t believe it seems to have gone unnoticed.

Jeffrey mentions that such an approach:

… arguably saves more bandwidth in the long run because a .css and .htc file can be cached, whereas conditional comments will linger on every response served. It also seems much better looking than the ugly looking conditional comments which only pollute your markup.

I’ve decided to add this method to the ongoing tweaks that I make to this website, and as such, HTML5 specific element support for Internet Explorer, is now handled via Jeffrey’s HTC file.