views:

98

answers:

3
+6  Q: 

Closing <script>

This is a stupid question, and I am aware that it is; but never the less, here it comes:

Is it possible to close a <script>-tag within itself, so to speak? I mean if you are using an external javascript-document can you close the tag like this:

<script type="text/javascript" src="xxx.js" />
+3  A: 

As far as I am aware of it, no.

Browsers usually ignore self closing script tags.

Adhip Gupta
Citation needed.
Török Gábor
This is where I had originally read this: http://webkit.org/blog/1273/the-html5-parsing-algorithm/
Adhip Gupta
A: 

If the document is XHTML served as XML, then yes, that's perfectly valid. If you're serving XHTML as HTML, however, it's not recommended as the SGML-style parsers that browsers use to processes tag-soup HTML may have a problem with it. (If you do decide to use self-closing script tags like that, be sure and test in several browsers first!)

bcat
Why the downvote?
bcat
I didn't vote down - I can't :) must've been a vicious lover...
Latze
Curses, I knew they'd find me here eventually! :)
bcat
Excactly :) They are sneaky...
Latze
+2  A: 

Have a look at this topic http://stackoverflow.com/questions/69913/why-dont-self-closing-script-tags-work

ppolyzos