Page 1 of 1
Does javescript files need the .js extension?
Posted: Mon Jul 02, 2007 3:44 pm
by JellyFish
It was interesting, when I changed the file extension of one of my JavaScript files to ".cl" it had no effect on my JavaScript file.
Aren't JavaScript files just text files? So why do they need the ".js" file extension in the first place? I guess it's a way to recognize the the file as a JavaScript file, in Windows Explorer. But other then that it's not necessary, is it?
Posted: Mon Jul 02, 2007 4:06 pm
by superdezign
The <script> tag defines the file type, not the extension. JavaScript isn't server-side, so the server doesn't handle the parsing, the browser does.
Posted: Mon Jul 02, 2007 4:14 pm
by JellyFish
superdezign wrote:The <script> tag defines the file type, not the extension. JavaScript isn't server-side, so the server doesn't handle the parsing, the browser does.
Exactly. Which is why I don't see why JavaScript needs any particular file extension, for that matter.
Posted: Mon Jul 02, 2007 4:24 pm
by Luke
most things don't NEED their extension. It would be kind of lame to try and figure out what belongs to what all the time if you didn't assign extensions to them
Posted: Mon Jul 02, 2007 4:41 pm
by JellyFish
The Ninja Space Goat wrote:most things don't NEED their extension. It would be kind of lame to try and figure out what belongs to what all the time if you didn't assign extensions to them
True. Extensions are necessary when it comes to that. But I'm was thinking of taking more of a Java approach with JavaScript by making my javascript files that define a class with the extension of ".cl".
Posted: Mon Jul 02, 2007 4:51 pm
by Luke
how about to make it easy on yourself... try filename.cl.js -- then you get the best of both worlds.
Posted: Mon Jul 02, 2007 5:00 pm
by JellyFish
The Ninja Space Goat wrote:how about to make it easy on yourself... try filename.cl.js -- then you get the best of both worlds.
I was thinking that. It might be more semantic in that manner.