I have the following scripts for dual language page (this is an overhaul of initial single-language webpage). What I am trying to achieve here if to change the words in HTML instead of using bulk edit function in Shopify or any other apps. However, if there are 1000s of them the webpage loading will be impeded seriously. Anyway to optimise it?
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" type="text/javascript"></script>
<script>
if ( window.location.href.indexOf(".com/zh") == -1) {
String.prototype.replaceAll = function(search, replacement) {
var target = this;
return target.replace(new RegExp(search, 'g'), replacement);
};
$("div").html(function() { return $(this).html().replaceAll("steady", "安定"); });
$("div").html(function() { return $(this).html().replaceAll("doctor", "医者"); });
;
}
</script>
Thanks.