Live data from Hacker News

Show HN: I created snapDOM to capture DOM nodes as images with exceptional speed

github.com

21–30 of 45 posts

Re: Show HN: I created snapDOM to capture DOM nodes as images with exceptional speed

#22
I’ve been writing a browser extension recently, and part of the functionality I want is to export part of a view as an image, shareable for the socials. I wanted to use html2canvas, but the docs explicitly advise against using it in a browser extension. Would snapDOM be suitable for inclusion in an extension?

Re: Show HN: I created snapDOM to capture DOM nodes as images with exceptional speed

#23
post #6

Earlier quoted context omitted.

Thank you for testing it out and sharing the screenshots! I’ve run some performance tests using Vitest Bench, and SnapDOM was faster. I also created a few manual demos, and SnapDOM won in both speed and accuracy. That said, I still need to run more real-world tests. So, thanks again for your help!

How can svg be faster, and especially more accurate (lets throw some IMG or CSS shadows for fun) than canvas?

You can embed HTML in an SVG via foreignObject. Seems like that's exactly what the library is doing[0].

Whether that's faster or more reliable, I don't know. Seems likely to render different depending on where you view the SVG (especially out of browsers).

[0]: https://github.com/search?q=repo%3Azumerlab%2Fsnapdom%20fore...

Re: Show HN: I created snapDOM to capture DOM nodes as images with exceptional speed

#25
post #24

I found puppeteer or playwright to be good at this with their screenshot method. I made a cli tool for this recently that worked quite well.

Yes they are so good. But in my case I need to work only on the client side

Re: Show HN: I created snapDOM to capture DOM nodes as images with exceptional speed

#26
post #17

Earlier quoted context omitted.

Hi! Insaw this API when I was starting to work on snapDOM but I thought it was not ok for my needs so I discarded it. Regarding other API it would be great if View Transitions API could exposed the old view in a future

What were your needs that the API didn't meet?

It requires user intervention and doesn't work for me.

Re: Show HN: I created snapDOM to capture DOM nodes as images with exceptional speed

#28
post #27

How does this compare with https://www.npmjs.com/package/dom-to-image-more ?

It is pretty the same idea. There are many good solutions like dom-to-imge-more: the battle tested html2canvas, dom-to-image, modern-screenshot, etc. SnapDom is focused on avoiding long-taks whenever is possible because was designed to a zoomble UI engine that needs the capture doesnt affect the transition. But this is the first public version and there many things to adjust.

Re: Show HN: I created snapDOM to capture DOM nodes as images with exceptional speed

#29
post #18

Maybe add a function to convert to PDF? I've always dreamed of converting an element or the document body to a long-scrolling PDF. I tried to implement it with Playwright Python, but I had no luck. The resulting PDF height is messed up.

Its a bit out of scope right now, but I thing it would be possible using some external libraries such as jsPDF or svg2pdf.js

Re: Show HN: I created snapDOM to capture DOM nodes as images with exceptional speed

#30
post #22

I’ve been writing a browser extension recently, and part of the functionality I want is to export part of a view as an image, shareable for the socials. I wanted to use html2canvas, but the docs explicitly advise against using it in a browser extension. Would snapDOM be suitable for inclusion in an extension?

Sincerely, I don't know if snapdom would work on a browser extension. I've never tested it on this scenery
Post reply on HN