Don't use JavaScript to fix your content. This is inefficient on a scale of ridiculous. Write your content correctly before you publish it or use some coding scheme on the server side. If this is some scheme to fix content that you don't control, such as user supplied, then simply state the content comes from your users and not you.
Seriously, this is going to delay the loading of your page significantly and cause visitors to abandon your site.