Is there any practical reason why you would write out a <noscript> tag with JavaScript’s document.write()? Our ad department has been doing this for years and still does it after I’ve pointed it out. I’m 99% certain that this is due to an ancient ad template written by someone who didn’t know what he was doing and no one has thought to change it because, “why fix what ain’t broke?” Or maybe someone is reading their “best practices” wrong (“Always include a alternative for browsers that have JS disabled”). Or maybe there’s a really good reason I don’t know about.
The only conceivable thing I can think of is that you could use it to modify the DOM without it appearing visible on the page and maybe use that content like a template for later use, but this seems pretty far-fetched.
(edit)
The tag in this case contains a standard <a href="/path/to/advertiser"><img src="/path/to/image" /></a>. Because this is what the original, non-dynamic ad tag would have looked like, this makes me think this is just copy-pasted garbage.
The other thing I should say is that the reason I’m not 100% sure this is an oversite is because of the recent pattern of putting html templates inside <script type="text/x-my-custom-template">...</script>. I’m sceptical that someone on our end would have come up with this on their own, but it could have been a standard ad practice by someone with unusual cleverness.
Nope. The two (
<script>and<noscript>) are mutually exclusive. It’s like writing a piece of code like this:If JavaScript is enabled, the browser ignores the
<noscript>tag. On the other hand, if JavaScript is disabled, the<noscript>tag will never be written, because the<script>tag is ignored.