javascript - Is a hash table faster than document.getElementById? -
If I have a node like this:
is buried under many levels of HTML and I also have a JavaScript hash table like this:
[/ * Many nodes * / 123: 'Test'} / * There are so many nodes / /
then it will be faster to use
document.getElementById ( 'Spn123') .innerText;
or
data (123)
I think the browser has taken care of the browser and These are very favorable, but could it be due to lack of flat structure and extra dom bloat later?
Thank you!
It may be useful to know why you have both objects and DOM representation That hash is the only source of truth and the DOM underscores the hash accordingly.
I hope the hash look faster, because the DOM may be slow, although it is mostly writing dom, not reading the dom I have created and the results differ significantly from the browser.
In these scenarios, I want to do a function to summarize the implementation so that it can be changed without getting every reference to lookup in the code. :
function getItem (id) {returns hash [id]; }
If you later search for a more customized way to see your data, then you change that function.
Update: I have changed JSF to use text content but do not work in older browsers.
Comments
Post a Comment