Jacksonville Developers User Group

Learn new things...write better code.
Welcome to Jacksonville Developers User Group Sign in | Join | Help
in
Home Blogs Forums

Jonathan Bates

HTML script tags must have a closing script tag

I was going to title this, "New Ways I Discover I Am An Embarrassing DumbAss", but here goes. . .

I was working on something, and importing a JavaScript library.  I was referencing it from a master page, in the head section, all was hearts and flowers.  I decided I was going to add in a plugin and I added in a line for that script and some accompanying CSS.  Hearts are broken, flowers dead.

I start to bang a soft spot in my head trying to figure this out.  Its funny how something that should work just doesn't and your entire world view is shattered.  I switched from IE7 to FireFox3.  Still no love.  No joy in Safari.  On a lark I try Chrome, and it does work as expected.  Now I am more confused, not less.

Going back to FF3, I look at the page via FireBug, and lo, there is the issue.  Only one of my imported scripts is being imported.  The problem?  I didn't close the <script> element with a </script>, so I was doing this:

<script src="./js/jquery-1.2.3.js" type="text/javascript" />

instead of this:

<script src="./js/jquery-1.2.3.js" type="text/javascript"></script>

So why would that be an issue?  If I had to guess, I'd say it has to do with the src attribute.  From the W3C:

The script may be defined within the contents of the SCRIPT element or in an external file. If the src attribute is not set, user agents must interpret the contents of the element as the script. If the src has a URI value, user agents must ignore the element's contents and retrieve the script via the URI. Note that the charset attribute refers to the character encoding of the script designated by the src attribute; it does not concern the content of the SCRIPT element.

So because its designed to get something from its own contents or from an external URI, the closing tag would need to be there for those cases when there are contents. I guess its just easier to work with knowing it always has a closing tag instead of holding two different parsing rules based on the src attribute.

Published Tuesday, October 07, 2008 3:12 PM by jonathanbates
Filed Under:

Comments

No Comments
Anonymous comments are disabled

About Jonathan Bates

Jonathan Bates is involved in the local development community, once even serving time as the President of the Jacksonville Developers User Group.

He has had a long and storied path on the way to I.T. work. At one point, Jonathan had a near Neo-Luddite position about computers, believing them at worst to be the means to humanity's eventual slavery and at best tools for general evil. After landing a job powered by such advanced technologies as Windows 3.11 for Workgroups and MS Access, Jonathan began to change his opinion on computers. He began to believe that they might be for more than just improving the display and sound qualities on his Laserdisc movies. In time, he came to see that computers were nothing more than tools, not much different then a hammer (though not as good to drive nails with).

Jonathan Bates is an industry-certified and proven developer and trainer, facilitating the transfer of knowledge from conceptual client request to delivered and implemented solution. Jonathan enjoys sharing his knowledge and understanding about development principals with like-minded people. You can generally find him enjoying good company discussing his personal Unified Theory and how programming can be used to describe it. And if you can't find him, drop him a line with a time and place and he'll find you.

Contact him at jonathan.bates@batener.org.

This Blog

Post Calendar

<October 2008>
SuMoTuWeThFrSa
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

Syndication

Powered by Community Server, by Telligent Systems