3 ms·
I'm not sure what the advantage of this is vs any standard server-side templating (PHP, Twig, Mustache, Liquid, etc.) Converting from a string to a DOM is very
by solardev 2y ago
I'm not sure what the advantage of this is vs any standard server-side templating (PHP, Twig, Mustache, Liquid, etc.)
Converting from a string to a DOM is very expensive because of all the non-XML non-standard cruft HTML accumulated over the years. If you can do a simple string find/replace instead, it should be less computationally expensive. No reason to actually parse the HTML unless you need to actually render it or at least work with it semantically/structurally, which doesn't sound like the case here.