469,360 Members | 1,726 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,360 developers. It's quick & easy.

Just learning.....

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
5 1072
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
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
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
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
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.

Similar topics

5 posts views Thread by Ron Stephens | last post: by
13 posts views Thread by Lumpierbritches | last post: by
42 posts views Thread by Andy | last post: by
2 posts views Thread by bokiteam | last post: by
5 posts views Thread by Hasin Hayder | last post: by
6 posts views Thread by MC felon | last post: by
21 posts views Thread by shotokan99 | last post: by
reply views Thread by Elizabeth Barnwell | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.