3 ms·
My JS is compiled from higher-level source; at the source level there is no duplication and it's simpler to use a variable. Moroever, using getElementById is 60
by gruseom 19y ago
My JS is compiled from higher-level source; at the source level there is no duplication and it's simpler to use a variable. Moroever, using getElementById is 60% slower than a global variable in FF and more than 10x slower in IE. For the app I'm building, this matters a lot.
- aston 19y agoOf course it's faster to use a precomputed reference than to find an element in the DOM. I can't see the "overhead" of manually storing a reference to a DOM element in a variable ever mattering in any application. Grab it once and you're done.
- eusman 19y agothe only sure thing is that the whole javascript perfomance/memory footprint/cross-browser/degrade challenge can drive someone crazy!