When passing data, using a runtime connection port, from an indexedDB database of an extension to the content script to build a document fragment to append to the page, would it be more efficient to build the fragment in the extension, serialize it to a string using XMLSerializer
and pass the string to be appended using insertAdjacentHTML
instead of passing the data and having a copy at each location?
After working with this further, it appears that I was being rather stupid in not considering the memory required to build the fragment in the extension just to serialize it to a string afterward. A few data objects are less than all the objects that need created to build the DOM tree to be serialized to a string.
In the content script, it may be possible to consume an amount of RAM once to hold the data passed and write the new data to the same object each time. However, in the background script, there appears to be no way of controlling where the get request is written; and in the content script there appears to be no way of controlling where the object passed in the communication port is held before being written to an object in the content script.
Whatever it is, it appears that it must consume less RAM overall than generating instances of elements for a DOM tree just to convert it to a string instead of passing only the data and building the tree in the content script.
Thank you.