Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster conversion from VDOM #82

Open
1 of 3 tasks
edemaine opened this issue Aug 8, 2022 · 0 comments
Open
1 of 3 tasks

Faster conversion from VDOM #82

edemaine opened this issue Aug 8, 2022 · 0 comments

Comments

@edemaine
Copy link
Owner

edemaine commented Aug 8, 2022

Currently we render VDOM to a string for duplicate detection, and then parse that string into xmldom in Node and actual DOM in browser.

  • We should be able to convert VDOM directly to xmldom/DOM via a simple recursion similar to preact-render-to-string. Need to benchmark, but this should be faster than parsing a string.
  • Alternatively, we could avoid xmldom on Node and just work with VDOM for the full document (and use Preact's render if we need to go to actual DOM). Not sure if/when this would be better, but perhaps worth experimenting with. Might also be beneficial for GUI?
  • Should we try to do duplicate detection without rendering to string? Maybe stringify nodes and use a Map to recursively find identical root nodes and recurse? Then we could avoid the string intermediate form altogether, except for final rendering to an SVG file. (Currently we stringify individual symbols and also stringify the final SVG file, and we should only have to do the latter.)
    • preact-render-to-dom benchmarking shows stringifying is only 20% of the stringify + parsing, or 4x faster than parsing, so this ends up being far less important than the first bullet.

Alternatively, we could always work with Preact instead of DOM. Then we wouldn't have to convert Preact at all (but would still have to parse strings). Code gets a little uglier (would need custom setAttribute).

edemaine added a commit that referenced this issue Oct 22, 2022
7x speed boost via new `preact-render-to-dom` package
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant