The project is to process and visualize high dimensional data. And we need to replace some text after the data has been loaded to the website. I found some threads on stackoverflow with more or less the same solution Replace text in HTML page with jQuery:
$('body :not(script)').contents().filter(function() {
return this.nodeType === 3;
}).replaceWith(function() {
return this.nodeValue.replace('-9o0-9909','The new string');
});
And this solution works well, it replaces exactly the searched text (regex) with the html code (e.g. 'word').Adding superscript tags around all trademark and registered trademark symbolsReplace ALL words in HTML or Swapping text in a DOM element with children JavaScript/jQuery. The problem is that we have to replace 10,000+ words and it takes a while. The time is not the issue, but the browser freezes during that process and you can't do anything. How can we avoid freezing the browser? I read about lazy loading for images and asynchronous functions, but I don't know how to apply this to text replacement. Any help is appreciated?
Edit: Here a jsfiddle