Activate your free membership today | Log-in

Thursday, August 21st, 2008

querySelectorAll is coming fast

Category: Browsers, CSS

<>p>

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:

JAVASCRIPT:
  1.  
  2.  
  3. function querySelectorAll(selector){
  4.   try {
  5.     return Array.prototype.slice.call(
  6.       document.querySelectorAll( selector ) );
  7.   } catch(e){}
  8.  
  9.   return myOtherLibrary( selector );
  10. }
  11.  

Less code. More speed.

Related Content:

  • HP aims Slate 500 Windows tablet at health care
    Don't look now, Apple, but the Hewlett-Packard Slate 500 tablet, running Windows 7, is coming up fast behind your...
  • How to limit damage from the MyDoom worm
    The fast-spreading MyDoom worm is potentially very dangerous. It may herald even worse things to come. Here’s what you should...
  • FastCGI
    FastCGI is a programming interface that can speed up Web applications that use the most popular way to have the Web server call an application, the...
  • XI
    Instrument file (FastTracker...
  • XT
    FastTracker Music...

Posted by Dion Almaer at 8:30 am
2 Comments

++++-
4 rating from 22 votes

2 Comments »

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.