performance problems with multiple assignments to the same DOM-node
git-j opened this issue · comments
In certain situations the hallojs editor component gets unusable over time. over time means with multiple invocations on the same dom-tree node.
the situation for my application is:
a list, that the user can select from
a editor div that contains the data displayed/modified to the user
when a list-item is clicked, the editor-div is filled with the data associated to the list and the editor has to be configured to be minimal (undo/redo only) or full (with more plugins)
essentially hallo() is called multiple times on the same dom-node:
for (i=0;i<100;i++)
$('#editordiv').hallo(myconfiguration);
after this, the editor component is painfully slow, it takes multiple seconds for a single typed character to appear. the leak seems to be in the loaded plugins, because with a minimal configuration the effect is noticed after more invocations
the current work-arround is to remove the node that hallo uses before reassigning the new configuration
for (i=0;i<100;i++){
var parent = $('#editordiv').parent();
$('#editordiv').remove();
parent.append('<div id="editordiv"></div>');
$('#editordiv').hallo(myconfiguration);
}
please review the example created for this purpose
https://github.com/git-j/hallo/blob/master/examples/test_multiuse.html