I\'ve been sifting around the web trying to find out whats going on here and I have not been able to get a concrete answer.
I have one $(document).ready
The ready event cannot fire twice. What is more than likely happening is you have code that is moving or manipulating the element that the code is contained within which causes the browser to re-execute the script block.
This can be avoided by including script tags in the or before the closing tag and not using $('body').wrapInner();. using $('body').html($('body').html().replace(...)); has the same effect.