I have some Javascript code that communicates with an XML-RPC backend. The XML-RPC returns strings of the form:
See the benchmark: https://jsperf.com/decode-html12345678/1
console.log(decodeEntities('test: >'));
function decodeEntities(str) {
// this prevents any overhead from creating the object each time
const el = decodeEntities.element || document.createElement('textarea')
// strip script/html tags
el.innerHTML = str
.replace(/