Felix Schütt Felix Schütt - 1 month ago 13
Javascript Question

Blogger: Prevent loading of widgets.js (2015)

I have a custom website on Blogger, using none of the templates, just regular code. My problem is the widgets.js file. It gets loaded every time, although I don't need it.

The problem is that in the past, it was easy to remove it by replacing the

</body>
tag with
&lt;!&#45;&#45;</body>&#45;&#45;&gt; &lt;/body&gt;


But now this doesn't work anymore, because of a comment that was added because of Googles cookie policy. This is the code I am getting on the webpage:

<!--<script type="text/javascript">
if (window.jstiming) window.jstiming.load.tick('widgetJsBefore');
</script>

<!-- 'Es liegt in Ihrer Verantwortung, Ihre Besucher über die in Ihrem Blog verwendeten Cookies zu informieren. Weitere Informationen finden Sie hier http://www.blogger.com/go/cookiechoices.' -->
<script src="/js/cookiechoices.js" defer></script>
<script>
Code for Bloggers Cookie Information that pops up on every page here
</script>

<script type="text/javascript" src="https://www.blogger.com/static/v1/widgets/2772432204-widgets.js"></script>
<script type='text/javascript'>
Some blogger script here, pretty long so I don't paste it.
</script>
</body>--> </body>

</html>


The original intention was to make the whole script tag a comment - but due to the changes in cookie policy Google added this comment, at least on EU sites:

<!-- 'Es liegt in Ihrer Verantwortung, Ihre Besucher über die in Ihrem Blog verwendeten Cookies zu informieren. Weitere Informationen finden Sie hier http://www.blogger.com/go/cookiechoices.' -->


The problem is - it gets automatically added on blogger and the "-->" blocks the hack from being effective.
What I've tried:


  • disabling the cookie notice:


    cookieChoices = {};

  • changing the country to not redirect from .com to .de:


    var blog = document.location.hostname;
    var slug = document.location.pathname;
    var ctld = blog.substr(blog.lastIndexOf("."));
    if (ctld != ".com") {
    var ncr = "http://" + blog.substr(0, blog.indexOf("."));
    ncr += ".blogspot.com/ncr" + slug;
    window.location.replace(ncr);
    }



None of it works though. I've search for hours for an answer. Thanks for reading my question.

Answer

Use this code &lt;!--</body>--&gt;&lt;/body&gt; It's work fine for me.