Black lives matter
Portrait Dr. Axel Rauschmayer
Dr. Axel Rauschmayer
Homepage | Twitter
Cover of book “JavaScript for impatient programmers”
Book, exercises, quizzes
(free to read online)
Cover of book “Deep JavaScript”
Book (50% free online)
Cover of book “Tackling TypeScript”
Book (first part free online)
Logo of newsletter “ news”
Newsletter (free)

es5-shim: use ECMAScript 5 in older browsers

[2011-02-07] dev, javascript, jslang
(Ad, please don’t block)

ECMAScript 5 (ES5) brings with it some nice improvements. The only problem is that only newer browsers (Internet Explorer 9, Firefox 4, Chrome 5, Safari 5) support it, or at least its most interesting parts. es5-shim provides a neat solution: It checks for each ES5 feature whether it is present and if not, it provides its own implementation. As an aside: es5-shim originated as a Narwhal module and was then turned into a stand-alone library, to encourage broader adoption. es5-shim is the more current version of the two.

Tip: Use the ECMAScript 5 compatibility table to find out whether you need the shim or not. When in doubt, just include it, as it auto-detects whether your browser is too old or not.