I'm writing an app that makes use of JointJS to display diagrams.
However, I want to be able to dynamically add and remove diagrams from a page. Adding new diagrams is fairly trivial, but when I remove diagrams, is it safe to remove the DOM elements and let the graph and paper objects get garbage collected?
Yes, that's almost it. Better yet is to call graph.clear()
(to remove all the cells from the graph and their associated views from the paper) and then paper.remove()
(to cleanup the paper from the DOM, including its event handlers).