performance - JS DOM elements’ content-string properties: memory management and computation in current engines -


in dom, node , element types have many dynamic properties, e.g., node.textcontent , element.innerhtml, return string representations of nodes’ contents.

the dom specifications state these methods “return” domstrings, i.e., strings. they, of course, not specify when , how these strings allocated , computed. text nodes, implementation can return plain-text string content directly. elements must create new strings contain tags , contents of descendant elements.

as far can tell, implementation may allocate memory these strings , compute values @ 4 points:

  1. immediately, when element first created;
  2. lazily, scheduled sometime after element’s creation;
  3. lazily, on demand @ point when getting string property element;
  4. or lazily, on demand whenever string first used (i.e., returned string uses special, externally indistinguishable implementation returned element’s string properties dynamically generates value when needed).

these methods determine when strings’ memory freed. first 2 techniques cache string in element object—they create reference string element, , string not deallocated until element is. third , fourth techniques might need not create such reference element; string’s memory may deallocated long before element is, long other references freed. in addition, implementation might use two, three, or of these possibilities based on heuristic.

which techniques modern browser engines use? question has clear performance ramifications, both in computation time , memory allocation, sort of dom manipulation , text retrieval. far can tell these properties’ performance characteristics unknown or not documented.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -