What’s the deal with CSS query engines?
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?
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
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.