Search code examples
htmlw3cw3c-validation

Nu HTML Checker reports mysterious script tag


This seems to be a common problem: Stray start tag returned by the Nu HTML Checker. My HTML reads </body>, while the Checker says </body>↩<script>'undef. The only usage of <script> is as follows:

<script src="Sternheimer.js"></script>
<!--<script src="../jquery-2.1.4.min.js"></script>-->
<script src="../jquery-3.1.1.min.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    tex2jax: {
      inlineMath: [['$', '$']]
    },
    menuSettings: { inTabOrder: false }
  });
</script>
<script type="text/x-mathjax-config">
  if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
    MathJax.Hub.Config({
      "HTML-CSS": { scale: 90 }
    });
  }
</script>
<script src="../MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script src="initializeForm.js"></script><!--run on page load-->
<script src="formFields.js"></script><!--reveal additional fields-->
<script src="../smoothScroll.js"></script>
<script src="../backToTop.js"></script>

... which is of course inside <head>. SO search results say the Checker could be misinterpreting comments, which I've checked by getting rid of <!--<script src="../jquery-2.1.4.min.js"></script>--> but the error persists. My markup is always validated using the W3C extension in Brackets. Please see the Nu result here. Any help resolving this mystery will be appreciated.


Update | Viewing the source on my hosting's server, I discovered the following was appended to my original markup: <script>'undefined'=== typeof _trfq || (window._trfq = []);'undefined'=== typeof _trfd && (window._trfd=[]),_trfd.push({'tccl.baseHost':'secureserver.net'}),_trfd.push({'ap':'cpsh'},{'server':'a2plcpnl0819'}) // Monitoring performance to make your website faster. If you want to opt-out, please contact web hosting support.</script><script src='https://img1.wsimg.com/tcc/tcc_l.combined.1.0.6.min.js'></script>. Mystery solved, and this appears to be fixable. Thank you for your help.


Solution

  • It is not a bug. I can type curl http://handcrafted.codes/Sternheimer/Sternheimer.htm and see the script tag after the body end tag.

    Presumably you are using hosting which injects snoop code at the end of HTML documents.