Lately, there seems to have been an explosion of client-side CSS query. The current offerings are:

The free market tends to work in such a way as to saturate itself when consumer demand is high, but I really question the value of these engines. Was there really a demand for CSS querying of a document? Or was this some experiment that eventually led to a series of one-ups from developers looking for a challenge?

Don’t get me wrong, I think the DOM is a crappy, inefficient API, but since it’s part of a browser’s underlying code, it will undoubtedly be much faster (depending on your use case) than any interpreted JavaScript syntax parser.

CSS queries also seem really inefficient and not very logical when compared to XPath queries, which is my favored DOM querying language (actually, I wish I could write style sheets to use XPath). In all my years as a frontend developer, I can’t remember a time when using a combination of getElementById() and getElementsByTagName() didn’t get my job done fairly quickly. I’ve never had any use for queries looking for elements with a given class name, or ones that want to find all descendant nodes of a given one, or any other thing that CSS querying claims to offer over using the provided DOM methods. If I need explicit access to an element, I give it an ID, or if I need to access a series of elements, I group them under a container and give that element an ID. Am I missing something?

Disclaimer: Any viewpoints and opinions expressed in this article are those of Nicholas C. Zakas and do not, in any way, reflect those of my employer, my colleagues, Wrox Publishing, O'Reilly Publishing, or anyone else. I speak only for myself, not for them.

Both comments and pings are currently closed.