3 ms·
That approach you describe to building an SVG tree is a common performance optimization when manipulating the DOM for HTML as well. I'd be curious to hear if yo
by notJim 15y ago
That approach you describe to building an SVG tree is a common performance optimization when manipulating the DOM for HTML as well. I'd be curious to hear if you've tried a) using a DocumentFragment, b) detaching the node using removeNode, manipulating, then adding it back, and c) simply working with a node (createNode) and then adding it in after manipulations are done. The basic idea is that working with the live DOM is slow, while working with detached nodes is fast. Note that I haven't really tried this stuff out that much. Maybe I'll work up a little benchmark over the weekend or something.
I'm pretty sure Paul Irish's talk [1, 2] is where I read about this.
[1]: http://www.slideshare.net/paul.irish/perfcompression http://www.slideshare.net/paul.irish/perfcompression
[2]: http://vimeo.com/10295601 http://vimeo.com/10295601
- gruseom 15y agoYes, using innerHTML to bypass the HTML DOM is the poster child for this kind of thing. We've tried all the alternative techniques you mention (with HTML DOMs, that is - I don't think any of them work with SVG) and had disappointing results.