Experiment in attaching nested Hypedocuments

I was playing around with nested Hype-Documents. Attaching them and destroying them again. It seams like the Chrome Garbage-Collector can’t remove them as they keep some backlink to the DOM.
I removed them from the window[‘HYPE’][‘documents’][documentName] and the DOM. The structure should be in theory detached (as it is selfcontained). Nodes and Listener keep going up.

Any insights here @jonathan?

page.hype.zip (13,6 KB)

I also found a code quirk. I guess from attaching styles/stylesheets on the fly… they are wrapped in a DIV in the head section. Could the DIV (not the styles) be avoided? Also if you could use the id or any other identification on could avoid duplication if not needed. Maybe a id based on the hype-file etc. and one for shared styles across all hype files.

Hype document don't have any support for being dynamically removed. This isn't a very common thing to want to do, though React-like libraries make it a bit more of a priority now. If you need to fully tear-down and build up Hype documents the best way to do it is with an iframe.

window["HYPE"]["documents"][documentName] only contains a reference to the API object; there will still be plenty of other entities that are holding onto references (timers etc).

This has been there since v1 but my recollection is this is required for some older browser support that would not pick up the style if it were injected directly. It should be harmless - are you encountering issues with it being there?

You are correct that it should probably be ID'd to the document. What goes here is general CSS default styling, but it could change if there's a different version of Hype or if the Use WebKit graphics acceleration box is different.