By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,384 Members | 714 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,384 IT Pros & Developers. It's quick & easy.

Just learning.....

P: n/a
Jim
Forgive me if this is a stupid question. I am completely new to javascript.

If a javascript refernces a javascript file (*.js), when the page is
displayed in a browser, does the page get the *.js file added as inline
code, or does a call to the *.js file require another trip to the server to
get and execute the *.js code?

Thanks!
Jan 19 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Jim wrote:
If a javascript refernces a javascript file (*.js), when the page is
displayed in a browser, does the page get the *.js file added as inline
code, or does a call to the *.js file require another trip to the server
to get and execute the *.js code?


It makes another trip to the server of course. For it to be otherwise the
server would have to process the HTML document and look for <script>s.
(Also, since it still works if you access it on your file system instead of
a webserver ...)

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jan 19 '06 #2

P: n/a
Jim

"David Dorward" <do*****@yahoo.com> wrote in message
news:dq*******************@news.demon.co.uk...
Jim wrote:
If a javascript refernces a javascript file (*.js), when the page is
displayed in a browser, does the page get the *.js file added as inline
code, or does a call to the *.js file require another trip to the server
to get and execute the *.js code?
It makes another trip to the server of course. For it to be otherwise the
server would have to process the HTML document and look for <script>s.


I thought browser may do like they do for an image....find each and download
it into the cache to show onscreen.

Since the browser does this (the image thing) I thought they may do the same
with *.js files.
(Also, since it still works if you access it on your file system instead
of
a webserver ...)


Thanks for the info!
Jan 19 '06 #3

P: n/a
Jim said the following on 1/19/2006 3:46 AM:
"David Dorward" <do*****@yahoo.com> wrote in message
news:dq*******************@news.demon.co.uk...
Jim wrote:
If a javascript refernces a javascript file (*.js), when the page is
displayed in a browser, does the page get the *.js file added as inline
code, or does a call to the *.js file require another trip to the server
to get and execute the *.js code? It makes another trip to the server of course. For it to be otherwise the
server would have to process the HTML document and look for <script>s.


I thought browser may do like they do for an image....find each and download
it into the cache to show onscreen.


It does, in a way. And when you execute a function that is in that
external file it does not re-download it from the server.
Since the browser does this (the image thing) I thought they may do the same
with *.js files.


It does.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 19 '06 #4

P: n/a
Jim wrote:
It makes another trip to the server of course. For it to be otherwise the
server would have to process the HTML document and look for <script>s.


I thought browser may do like they do for an image....find each and
download it into the cache to show onscreen.


Yes, it does. That's what I said.
--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jan 19 '06 #5

P: n/a
On 2006-01-19, Jim <re***@groups.please> wrote:
Forgive me if this is a stupid question. I am completely new to javascript.

If a javascript refernces a javascript file (*.js), when the page is
displayed in a browser, does the page get the *.js file added as inline
code, or does a call to the *.js file require another trip to the server to
get and execute the *.js code?
most servers and browsers implement something called "keepalive" this often
means the script although separate is asked for and arrives through the same
connection that delivered the page.
Thanks!


--

Bye.
Jasen
Jan 19 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.