52

Beginner at Rails.

I'm coding CSS in my sample application. I understand there is Javascript code to help browsers, i.e. Internet Explorer, support HTML5.

What is the difference between HTML5 Shim and HTML5 Shiv? Is it something worth knowing?

http://html5shim.googlecode.com/svn/trunk/html5.js

http://html5shiv.googlecode.com/svn/trunk/html5.js

My code, y'all:

<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js">
</script>
<![endif]-->
5
  • Nothing. Both are /*! HTML5 Shiv vpre3.6 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed.
    – user824425
    Commented Jan 20, 2013 at 20:43
  • 3
    "Answer: nothing, one has an m and one has a v - that's it." - html5shim
    – Mohammed H
    Commented Oct 28, 2013 at 11:39
  • 1
    html5shim doesn't exists with bower Commented Jan 11, 2015 at 16:42
  • 3
    While not directly related to the question, its worth noting that calling the code respository from your site is incorrect as per stackoverflow.com/questions/9578027/… due to several issues including its not minified or compressed with gzip, and has a very short TTL. Instead use cdnjs.com/libraries/html5shiv to find the right CDN hosted copy. Commented Nov 26, 2015 at 2:21
  • 1
    Paul Irish's exhaustive explanation, with timeline!
    – chb
    Commented Nov 16, 2017 at 18:28

4 Answers 4

83

It was originally called the html5-shiv.

Shiv really isn't the right term, as a shiv is a stabbing-implement.

A shim is something which you use to level things out (or prop them up). If a table has one leg that's too short, you might shim it with a piece of wood or a phone book...

So html5-shim is for people who expect html5shiv to be called a shim.

That's entirely it, as far as differences go.

Kind of like polyfills cover over the differences in implementations of features.
In North America, Polyfill might be called "Spackle".

4
  • 7
    Thanks! It's difficult to know what is worth knowing when learning new concepts.
    – owlstone
    Commented Jan 20, 2013 at 21:14
  • 9
    No-one would want to stab Internet Explorer, would they? ;-) Commented Jun 19, 2015 at 14:11
  • 3
    @HenryRusted I might be picturing any wide-scale scene where a whole gang gets shivved, in cutscenes... The killers leave, the camera pulls back, and it's IE5.5, IE6, IE7, IE8, IE9, IE10, Android 2.3, most Mobile Safari... Breaking Web.
    – LetterEh
    Commented Jun 19, 2015 at 14:17
  • So a shiv is for @#@$ing someone up, and a shim is a fine tuning or poyfill a gap filler. Shiv actually suggests something is going to be done a mischief.
    – mckenzm
    Commented Nov 24, 2021 at 2:09
26

From http://code.google.com/p/html5shim/

shiv or shim?

Common question: what's the difference between the html5shim and the html5shiv?
Answer: nothing, one has an m and one has a v - that's it.

14

The answer is.

The term shiv originates from John Resig, who was thought to have used the word for its slang meaning, a sharp object used as a knife-like weapon, intended for Internet Explorer. Truth be known, John probably intended to use the word shim, which in computing means an application compatibility workaround. Rather than correct his mispelling, most developers familiar with Internet Explorer appreciated the visual imagery. And that, kids, is etymology.

From author's page at https://github.com/aFarkas/html5shiv

0

This is probably more simple than you're looking for, but for others who may be confused:

First, here's a non-programming definition of a Shim:

noun: a washer or thin strip of material used to align parts, make them fit, or reduce wear.

verb: wedge (something) or fill up (a space) with a shim.

To understand a shim in programming terms, you need to understand what a pain IE was/is for web developers:

IE was one of the first commercially-available web browsers. And it may have been the first one available "for free". Thus, it was built before browser standards were defined, ie definitions of how to handle html and javascript.

So, in order to keep sites and applications working in IE, as standards were produced, IE could not or (for monopolistic reasons) would not update IE (here's a great post with more info about that). This caused a rift between IE and other browsers that grew over time. This rift often surfaced in unexpected errors, styling differences, and some applications straight-up refused their users the option of running it from other browsers.

But, if a product was going to be available for both types of browser, developers often had to write two sets of code. One for practically every modern browser, and one for IE. Obviously, this practice made upkeep a nightmare. But, as time progressed, many JavaScript frameworks/libraries started adding code to specifically address these issues. These pieces of code are known as shims. Because they're making your code "fit" in IE.

For instance, when jQuery was first released, a major advantage it had over its predecessors - or just writing your own library - was that it worked in every Browser, even IE. At the time IE was still heavily used, so this saved developers a lot of time. But now jQuery is on version 3. And the major difference between previous versions is that it no longer supports IE. That's because everyone, even Microsoft has sorta moved away from IE (Win10's default browser is Edge). But, unfortunately many sites and web applications were designed specifically for IE (for security reasons). And even though IE has gone the way of the Dodo for most commercial applications, it still offers security features that other browsers don't (but they're catching up quickly). And even if they did, the cost of updating these applications is often too great to be justifiable.

And that basically means many people still are forced to use IE, so these shims are still necessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.