Include JavaScript file in HTML will not work as <script .... / ">
I would like to include a javascript file on every page of the site. I can do this with:
<script type="text/javascript" src="myFile.js" ></script> This works fine - however, since there is nothing between the two tags, I would like to change it to:
<script type="text/javascript" src="myFile.js" /> If I do this, it will not work - nothing after this line is loaded onto the page.
Any ideas why? Thanks
Unfortunately, the HTML specs for REQUIRE are the closing tag ...
HTML Standard Section 18.2.1
18.2.1 SCRIPT Element
Start tag: required ; end tag: required

This is not a mistake, this is standard behavior.
In addition, empty HTML elements are often not displayed:
<div style="background:red"></div> , <div style="background:red" /> not
HTML does not support self-closing tags. If you want to use them, you need to use xype-based doctype AND serve the file as xml.
XHTML or xml html5 serialization will work.
Here is an example:
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>XHTML5 Template</title> <meta charset="utf-8" /> <script type="text/javascript" src="http://documentcloud.github.com/underscore/underscore-min.js" /> </head> <body> </body> </html> Save this in a file with the extension .xhtml and open it in a modern browser, and the closing tag itself will work.