News for hackers. Stuff that matters.
Re:Show HN: I created snapDOM to capture DOM nodes as images... by krebby on Sunday April 27, 2025 @01:36PM (#43813674)
How does this compare to something like the the Media Capture API? Looks like this uses `canvas.toDataURL()` which can be slow to serialize compared to `toBlob` or `canvas.captureStream(0).getVideoTracks()`

I've been using CropTarget.fromElement with a CaptureController: https://gist.github.com/akre54/e93ab2ce27999aecb109e38085f2e...

Re:Show HN: I created snapDOM to capture DOM nodes as images... by tinchox6 on Sunday April 27, 2025 @02:25PM (#43814029)
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
Re:Show HN: I created snapDOM to capture DOM nodes as images... by krebby on Sunday April 27, 2025 @02:40PM (#43814136)
What were your needs that the API didn't meet?
Re:Show HN: I created snapDOM to capture DOM nodes as images... by tinchox6 on Sunday April 27, 2025 @03:58PM (#43814650)
It requires user intervention and doesn't work for me.
Re:Show HN: I created snapDOM to capture DOM nodes as images... by streptomycin on Sunday April 27, 2025 @01:58PM (#43813858)
Looks cool, somebody should make a package that puts a nice API around it. However seems that those APIs are only in Chrome now, not Firefox or Safari.
Re:Show HN: I created snapDOM to capture DOM nodes as images... by krebby on Sunday April 27, 2025 @02:49PM (#43814202)
IMO it's simple enough to just write directly without library code.

For most cases, the Element Capture or Region Capture API should be sufficient: https://developer.mozilla.org/en-US/docs/Web/API/Screen_Capt...

Demos: https://mdn.github.io/dom-examples/screen-capture-api/elemen... https://mdn.github.io/dom-examples/screen-capture-api/region...

If you need cross-browser compatibility (and can't just use a canvas) then yeah html2canvas is the way to go

Re:Show HN: I created snapDOM to capture DOM nodes as images... by streptomycin on Sunday April 27, 2025 @09:12PM (#43816586)
idk, your code is 170 lines, html2canvas and similar are 1 line to use.
Re:Show HN: I created snapDOM to capture DOM nodes as images... by tinchox6 on Sunday April 27, 2025 @04:36PM (#43814902)
I tested it on Chrome, Firefox and Safari