Categories
AjaxJavascript

Faster DOM Queries

Dean Edwards has posted a demo with a cross browser way of super quick DOM queries.

Limitations

* As described earlier, speed improvements only apply on page load for IE. Further DOM queries will use the original getElementsBySelector function
* the speed of CSS2 queries (attribute selectors) are not improved for IE5/6
* because of the nature of the CSS hack, you can only apply one behavior per element :-(

Conclusion

* DOM queries on Firefox seem pretty quick
* XPath is about 150% faster than DOM queries on a Mozilla platform
* XPath is about 1000% faster than DOM queries on an Opera platform
* the expression hack is about 200-400% faster on an IE platform
* Behaviour leaks like a sieve

Kevin Henrikson

Kevin Henrikson

Kevin has spent his career making annoying but important things work better at scale: enterprise email at Zimbra, mobile productivity (co-founded Acompli, acquired by Microsoft for $200M and became Outlook Mobile), marketplace operations at Instacart, and now healthcare administration as Co-Founder of Pretty Good AI.

Subscribe to my newsletter - Founder Mode