May 2017
Intermediate to advanced
448 pages
10h 10m
English
The rule of thumb about selector performance applies equally to DOM traversal performance: we should prioritize ease of code writing and code maintenance when possible, only sacrificing legibility for optimization when performance is a measurable problem. Again, sites such as http://jsperf.com/ are helpful in determining the best approach given several options.
While premature optimization should be avoided, it is good practice to minimize repetition of selectors and traversal methods. As these can be potentially expensive tasks, the fewer times we do them, the better. Two strategies for avoiding this repetition are chaining and object caching.
Read now
Unlock full access