1

When I reference jQuery, using the first script reference, every thing is fine, however if I just replace the closing tag with />, jQuery works fine!!, however, a java script library domtab.js stop working. that applies on FF and IE.

Why?, I don't think it is a bug that in all browsers, there is something I miss.

    <!--ok-->
    <script type="text/javascript" language="javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" ></script>

    <!--Replace-->
    <script type="text/javascript" language="javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" />

    <script type="text/javascript" src="/domtab.js"></script>

Thanks

Costa
  • 3,897
  • 13
  • 48
  • 81
  • possible duplicate of [Why don't self-closing script tags work?](http://stackoverflow.com/questions/69913/why-dont-self-closing-script-tags-work) – JJJ Oct 19 '11 at 12:45

1 Answers1

5

You cannot self-close a script tag. You have to use </script>.

If you use />, the following text will be interpreted as the script source up to the next occurrence of </script>. That's why your second script does not work.

The HTML specification denotes script element end tags as required. This is because HTML character escaping rules are not in effect for script contents (i.e. you can use otherwise reserved characters like < or & without encoding them as &lt; or &amp;). As a result, a fixed "end contents" marker is required, which just happens to be </script>.

Tomalak
  • 332,285
  • 67
  • 532
  • 628
  • This question has further info - http://stackoverflow.com/questions/69913/why-dont-self-closing-script-tags-work – ipr101 Oct 19 '11 at 12:43