HTML5 Posted August 25, 2010 Share Posted August 25, 2010 Why is an external link to a javascript file defined as <script type="text/javascript" src="myjavascript.js"></script> and not in a <link> tag like css? Link to comment Share on other sites More sharing options...
Ingolme Posted August 25, 2010 Share Posted August 25, 2010 That's a good question. The HTML 4.01 specification doesn't seem to say anything about it. Link to comment Share on other sites More sharing options...
Howdy_McGee Posted August 25, 2010 Share Posted August 25, 2010 So the browser can tell the difference between CSS and Javascript. Also because javascript is commonly known as a "script". I doubt there's any real technical reason. Link to comment Share on other sites More sharing options...
boen_robot Posted August 25, 2010 Share Posted August 25, 2010 So the browser can tell the difference between CSS and Javascript. Also because javascript is commonly known as a "script". I doubt there's any real technical reason.If that was the reason, then they might as well have let the <style> element have a src attribute for consistency, and let developers only use "link" for "unknown" at the time of writing stuff, such as favicons and RSS feed links.I'm guessing the only reason we have the link in a script element is because of the browser wars at the time - JavaScript was originally a Netscape extension, and they put it out for standartization only after implementing it in their browser (as Microsoft also did with their own extensions). There were no namespace mechanisms, so Netscape poisoned the global namespace by calling the hook element "script", and when standartization came, the W3C WG probably said "well... it's already implemented like that... probably not so good puristically speaking, but it works... anyone against? Microsoft? No? You've already implemented it like that? Oh, OK.". Link to comment Share on other sites More sharing options...
HTML5 Posted August 26, 2010 Author Share Posted August 26, 2010 Yeah, that's probably it. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.