About the class selector, most modern browsers now have a function called getElementsByClassName, which is implemented nativly, and is therefore really quick. Even the most complex selectors (try "[name~='a'] [href~='#login']" for example) is still really fast because modern browsers have the selectors API.