jarrin
News
Interests
My House
Personal
Feedback
Garage Sale
Donate


Search just this section


 

jQuery Selector Performance
I just got done spending a few hours debugging some slow jQuery and thought that I should share the summary of my findings with the world at large. Always try to use an id or class designation when selecting DOM elements. For example, on a page with about a megabyte of HTML I had this selector:
var firstRow = ("#aspxGrid table tr td table tr:first");
That one line took nearly eight seconds to execute. I poked around in the HTML a bit and was eventually able to change it to (approximately):
var firstRow = ("tr#_DXHeadersRow");
That line now executed in just one millisecond. Say it with me, "just one millisecond". I hope you've learned something today.

Comments:

There are currently no comments.

Add a comment:
Name:
Email:

Journal

Previous Item:
DNS Change

Next Item:
A Nice Day For Ducks