3 ms·
My understanding is that modifying and querying DOM elements is what's slow, not just creating them. http://jsperf.com/lazy-url-parsing http://jsperf.com/lazy-
by zachrose 14y ago
My understanding is that modifying and querying DOM elements is what's slow, not just creating them.
http://jsperf.com/lazy-url-parsing http://jsperf.com/lazy-url-parsing
- exogen 14y agoI'm actually surprised it's only ~40% slower (in my Chrome anyway). Considering how much less code it is to maintain, that's totally worth it IMO. I'm sure there are a thousand other functions you'd want to optimize in a real app before this.
- yahelc 14y agoAdded a test case for not caching the DOM element: http://jsperf.com/lazy-url-parsing/2 http://jsperf.com/lazy-url-parsing/2