I am running some code in NodeJS to remove script tags before executing the scripts. Is there a simple way to do something similar in a browser environment?
import cheerio from "cheerio";
export async function removeScripts(serializedSvg: string): Promise<string> {
const $ = cheerio.load(serializedSvg, {
xmlMode: true,
decodeEntities: false,
});
Array.from($("script")).forEach((el: CheerioElement) => {
$(el).remove();
});
return $.xml();
}