Why would I put an ID on a script tag?

html, javascript

Solution

The one use I've seen of this is if you want to provide widget for customers and you instruct them to place the `<script>` tag wherever they want the widget to show up. If you give the `<script>` element an ID then you can reference that inside of it to place the code in the right place. That's not to say that it is the only way of achieving that, of course, but I've seen it done and suggested it in the past.

Problem

I've noticed that some web developers put IDs on scripts tags. For example: ``` <script id="scripty" src="something.js" type="text/javascript"></script> ``` I know that according the W3C this is perfectly legal markup, but what's the benefits of doing this?

Original source

Related problems