Thursday, August 21st, 2008

querySelectorAll is coming fast

Category: Browsers, CSS

We have all been talking about querySelectAll for awhile, but John Resig gives us a wrap-up that covers the state of play.

He talks about the browsers, and the libraries that wrap them and clean up shop via code like:


  1. function querySelectorAll(selector){
  2.   try {
  3.     return
  4.       document.querySelectorAll( selector ) );
  5.   } catch(e){}
  7.   return myOtherLibrary( selector );
  8. }

Less code. More speed.

Posted by Dion Almaer at 8:30 am

3.8 rating from 27 votes


Comments feed TrackBack URI

I’ve been wondering what “querySelector” meant since the first time i read it (just ignored it since it sounds boring).
Now i read that it just means getElementsBySelector() whcih immediately tells anyone who ever used getElementById or getElementsByTagNamw what it does.

Why in the world would you use a puzzling name like querySelector in stead of a self-explanatory name like getElementBySelector?

Comment by Jaaap — August 23, 2008

Second that. A “query selector” would be something that selects queries. To be more specific, it only works with CSS selectors. In Hpricot you can use either XPath or CSS selectors, which is much nicer.

Comment by randomrandom — August 24, 2008

Leave a comment

You must be logged in to post a comment.