• 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

Javascript functions and js file

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I have a doubt in js file.
I have an HTML page in which i write all javascript functions that i need.
I have another HTML page in which i just write a script tag as
<script language="javascript" src="file.js">
where i write all my javascript functions in "file.js" file.
so what will be the difference in both the conditions?
Will the performance be improved in the later case.
Plz Explain in detail.
Swamy
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is what i know about using external files.it is a quote from a tutorial


Sometimes you might want to run the same script on several pages, without writing the script on each and every page.
To simplify this you can write a script in an external file, and save it with a .js file extension

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
True, plus it's nice to hide your javascript code somewhat, if you have concerns about people stealing your code, or if you have any info (password, etc) that you want to hide. However, a knowledgeable user could find his way to your javascript page anyway by finding your reference to the js file, so it isn't perfect security (or even that good).
I tend to use this mostly in the interests of simplification. If you keep your javascript external, and use includes for headers and footers, etc, and use style sheets, you can end up with a very simple content page.
reply
    Bookmark Topic Watch Topic
  • New Topic