Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

external scripts & images - how does it loads? 1

Status
Not open for further replies.

baad

Programmer
Apr 10, 2001
1,481
RU
Hi all!

When i have a function in an externall file:

function changeSource(){
var str='<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>';
str+='<TR><TD><IMG SRC=&quot;pp-3__01.jpg&quot; WIDTH=102 HEIGHT=121 border=&quot;0&quot;></TD>';
str+='<TD><IMG SRC=&quot;pp-3__02.jpg&quot; WIDTH=102 HEIGHT=121 border=&quot;0&quot;></TD></TR></TABLE>';
return str;}

and then i do smthng like objID.innerHTML=changeSource() what would happen to da pictures? (pp-3..jpg) would they be loadin just when this script loads (i mean by <script src='extrnl.js'></script>) or only when i call changeSourse() from this script?
What if i have a lot of such functions with a lot of pictures - would it slow down da page loadin?
 
It would slow it down, and they would load when you called the function... your better off to preload your images:


and call one function that you pass a parameter to:

changeSource(thepic)
{
var str='<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>';
str+='<TR><TD><IMG SRC=&quot;pp-3__01.jpg&quot; WIDTH=102 HEIGHT=121 border=&quot;0&quot;></TD>';
str+='<TD><IMG SRC=&quot;'+thepic+'&quot; WIDTH=102 HEIGHT=121 border=&quot;0&quot;></TD></TR></TABLE>';
return str;
} jared@eae.net -
 
hi!

>jaredn:
agreed with preloading !!
but i think i shuld pass not url(src) but name of new image; am i wrong? shuld i pass both of them or lets say when i pass (like you said) just a source of image, wuld it understand that this image have been already preloaded?

thunx - i'm growing above myself!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top