Videogamer555 Posted September 26, 2012 Share Posted September 26, 2012 Often times I see a block of JS code like this: <script type="text/javascript"><!--some JS codegoes here//--></script> Since it already has the script tags to define the starting and stoping places of the JS code, are the <!-- and the //--> tags really neccesary? Why doesn't it just get written like this?: <script type="text/javascript">some JS codegoes here</script> On another note, do the <script> tags always have to be in the <head> section of the HTML document? Or can they also be in the <body> section? Or are they used in different sections based on specific needs of how specific parts of teh JS code it will be "activated"? Link to comment Share on other sites More sharing options...
justsomeguy Posted September 26, 2012 Share Posted September 26, 2012 Those comments are for old browsers that don't understand Javascript. No one uses those any more, all modern browsers will understand Javascript even if they are set to not execute it. Script tags can go in the body also. Link to comment Share on other sites More sharing options...
niche Posted September 26, 2012 Share Posted September 26, 2012 (edited) That's just the way someone is directing you to put your code there. Here's the link for js comments http://www.w3schools...js_comments.asp js can go in the head or the body or can be external. http://www.w3schools.com/js/js_whereto.asp Edited September 26, 2012 by niche Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now