WebKit gets native getElementsByClassName

Written by on December 24th, 2007 in Ajax News.

getElementsByClassName has always been a pain in the arse for us developers. Why it wasn’t implemented natively across the board is something that browser folk can chat about. Not having it available has caused hacks, workarounds, and bugs.

Firefox and Opera support the beast, and now Webkit has joined them:

The advantages of a native implementation are clear:

  • No additional JavaScript library files required
  • Clearly specified and consistent behavior
  • Blindingly fast

How fast? Let’s have a look at WebKit’s shiny new implementation. For testing purposes I wrote a simple benchmark allowing comparison between three different methods for getting elements by their class names. The first is the new native getElementsByClassName, and the last two are both from prototype.js; one uses XPath, and the other is a straight JavaScript/DOM implementation.

Source: Ajaxian
Original Article: http://feeds.feedburner.com/~r/ajaxian/~3/205567010/webkit-gets-native-getelementsbyclassname

Comments are closed.



Site Navigation