How to convert SVG to PNG with JavaScript

For information on this web page, please see the page below.

Original method

const svgDataBase64 = btoa(unescape(encodeURIComponent(svgData)))
const svgDataUrl = `data:image/svg+xml;charset=utf-8;base64,${svgDataBase64}`
Original method demo

Proposed method

const blob = new Blob([svgData], {type: "image/svg+xml" })
const svgDataUrl = URL.createObjectURL(blob)
Proposed method demo