Basic questions about JS images

G

GeezerButler

I thought JS was purely on client side. But if i do myImage.src =
'someImageOnServer.gif", it seems to work.
How does JS do this?
Is a request sent to the server when this line of code is executed? If
yes, then what kind of technique does JS use for loading this image.
OR
Do browsers download all server images when an initial server request
is made, put it in some client side cache and later JS accesses this
cache.
OR
some other mechanism?
 
T

Thomas 'PointedEars' Lahn

GeezerButler said:
I thought JS was purely on client side.

You thought wrong. Have you got this idea through a (bad) book by any chance?
But if i do myImage.src = 'someImageOnServer.gif", it seems to work.

However, there is no contradiction here. The code is probably executed
client-side (there is an indication, but no necessity) which would make this
client-side script code. What resources a code accesses is not relevant in
order to decide where it is executed.
How does JS do this?

Client-side scripting frequently uses the capabilities of the Web client
that provides its execution environment.
Is a request sent to the server when this line of code is executed?

That much would seem to be obvious for resources provided by a HTTP server.
If yes, then what kind of technique does JS use for loading this image.

The capabilities of the Web client.
OR Do browsers download all server images

An HTML user agent does not distinguish between client and server. The
image is referenced by a URI or URI-reference, and the URI of the document
or the URI of the supposed image resource defines how the Web client is
acquiring the image data.
when an initial server request is made, put it in some client side cache
and later JS accesses this cache.

No. The Web client usually has a cache (in memory or on disk). Client-side
scripting can indirectly make use of this cache if it accesses features that
are handled by the Web client.
OR some other mechanism?

What other mechanism could be there?


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top