The best placeholder polyfil script for ie7, ie8 and ie9

Jujhar Singh picture Jujhar Singh · Mar 15, 2013 · Viewed 27.1k times · Source

Which placeholder polyfill script do you recommend that I use to provide placeholder support in ie7, 8 & 9.

I've seen the following list from the modernizer team and was wondering if anybody here had some mileage with them or any others not on the list and what they think is the best

My criteria for evaluation would be:

  • File Size
  • Ability to work without modernizer/yepnope
  • Speed (no crazy looping)
  • Stability, how much as it been used in the wild?
  • Detect native placeholder ability and not bother running

I remember a day when I used to write a line or so in the onclick event of an input for placeholder support - lol, but to be honest I can't bothered to support these horrible browsers (watch this funny). At least IE10 is finally moving in the right direction.

Thank you...

Answer

Elijah Manor picture Elijah Manor · Mar 15, 2013

I recommend you use the jQuery Placeholder polyfill by Mathias Bynens.

  • It supports IE6+
  • It is 2k minified
  • It does its own feature detection (Modernizr isn't needed)
  • The code is straightforward. The jQuery selection will vary depending on your selector
  • It is the one polyfill recommended by HTML5Please and is listed on the Modernizr Wiki you mentioned
  • It doesn't execute the code if it isn't needed