Website blank when using Piwik


Have been using Piwik for some time now. I recently added the following jQuery code to a website

$(document).ready(function () {
    var replaced = $("body").html().replace(/my_val/g,'replace_val');

The code globally replaces ‘my_val’ with ‘replace_val’ within the body of a web page once the document has completed loading. By design, all instances of ‘my_val’ are within links, e.g.,

Now, in IE, the website loads, goes blank and the page source is replaced with

<script src='http://mypiwikstatsdomain/piwik.js' type='text/javascript'></script>

The above is the only thing visible when viewing the page source. In Firefox the page simply hangs.

When the jQuery code is removed the page loads as expected. For now I have removed Piwik from the site but would appreciate any insight into whether there is something I could do (have only tried deactivating plugins so far).


I dont think it’s correct to do this global replace on the body of the document, as I believe it screws the DOM event bindings and possibly other things. try another solution to replace the text…

Thanks. Sometimes it just needs to be said in a clear way like this :slight_smile:

A global replace was not the correct approach to take for the reasons you mentioned. Things are now working as perfectly as they were before (tu).