storing references to nodes during recursion
I don't know much about the DOM so forgive my ignorance.
At the moment, my code recurses all the nodes in a div and pushes the text nodes onto an array that I later access.
Which works fine, but if the document is very large it takes a few seconds to do this. The document I am working with at the moment ends up with an array of 3,880 text nodes in it, which takes about 5 seconds to compile.
So what I was thinking is it would be better, in the recursion, to just be storing a reference to those nodes rather than the nodes themselves.
I know that there is a nodeList (although I don't know if that includes nested elements or if each child node has its separate nodeList), but to me I think ideal would be to push the index of the node onto the array during recursion and then later to access it by something like
but is that possible, and would it work?
(and I guess more importantly, will it be significantly quicker than storing the nodes themselves?)
thanks for any thoughts...