Jan 302013
 
 January 30, 2013  Posted by at 11:32 pm Not So Stupid Questions  Add comments

[To celebrate my first year of programming I will ask a ‘stupid’ questions daily on my blog for a year, to make sure I learn at least 365 new things during my second year as a developer]

What is a shim?

What is a shim?

Putting the final touches on the exam project me and PA have been doing I had my colleague James look over our jade markup. “What do you think, pretty?” He had been using the serenade.js template language also inspired by HAML (and Jade), last summer I was in on that project and I had a hard time wrap my head around it but I really like it now. “Have you added any shims?” He asked. “What is a shim?” I asked back.

Let’s find out!

The dictionary explanation of a shim is:

A thin, often tapered piece of material, such as wood, stone, or metal, used to fill gaps, make something level, or adjust something to fit properly.

And what does this have to do with programming? Well, shims are application workarounds that help fit when there are compatibility issues. It’small library makes an older part of an application (that has to be kept and can’t be redone) work with the new additions/changes. Think of it as a compatibility layer. The shim James was referring to was one for HTML5, more specific the HTML5Shiv, which enables styling of HTML5 elements in IE explorer versions sub 9.

Adding HTML5Shiv
[sourcecode language=”html”]
//
<!–[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]–>
[/sourcecode]
In Jade
[sourcecode language=”html”]
//[if lt IE 9]>
script(src=’http://html5shiv.googlecode.com/svn/trunk/html5.js’)
//<![end if]
[/sourcecode]
So the shim was added to the project, and I learned something new. They really do have a name for everything, and a library for everything, a fix for everything. Except the iPhone viewport scale bug. But that is a whole other story.

  2 Responses to “Stupid Question 139: What is a shim?”

  1. Thanks for the article! I’ve just encountered shims myself in javascript. Great stuff!
    Btw, I’ve never used jade, but judging from html example, shouldn’t it read lt (less than) instead of gt (greater than) in the jade example?

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

What is 5 + 15 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)