• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

script tag in head section vs body section

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
head
script language="javascript" src="<%=appRoot%>/common/scripts/application.js"> /script
/head

and

body
script language="javascript" src="<%=appRoot%>/common/scripts/application.js"> /script
body
[ October 06, 2006: Message edited by: Bear Bibeault ]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Only real difference is when it gets rendered.

Eric
 
rama murthy
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Scripts in the head section:
Scripts to be executed when they are called, or when an event is triggered, go in the head section.

Scripts in the body section:
Scripts to be executed when the page loads go in the body section.

Is this correct. Is this a standard to be followed.
 
rama murthy
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eric I didn't understand what you said.

Kindly let me know whether what I said was correct.
 
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmph, have to admit I didn't even know you could do the body version

I'd be curious if there was any reason to do one vs. the other too... Eric's comment about when it gets rendered makes me think you might use the body version if timing might be important, i.e., you need the entire head to be processed before the script executes... I can't off the top of my head envision the situation where that would come up, but I don't doubt it exists.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic