/    Sign up×
Community /Pin to ProfileBookmark

preload images?

hi all,

i have 50 hidden div layers with images insided, each is appr. 200kb big.

i use this script to show/hide them, when neccesary:

[CODE]function init() {
IE = (document.all)
NC = (document.layers)
Opera = (document.getElementById)
}

function hide(id) {
init();
if(IE) eval(‘document.all[id].style.visibility = “hidden”‘)
if(NC) eval(‘document.layers[id].visibility = “hidden”‘)
if(Opera) eval(‘document.getElementById(id).style.visibility = “hidden”‘)
}

function show(id) {
init();
if(IE) eval(‘document.all[id].style.visibility = “visible”‘)
if(NC) eval(‘document.layers[id].visibility = “visible”‘)
if(Opera) eval(‘document.getElementById(id).style.visibility = “visible”‘)
}
[/CODE]

the code is used, when i click on some link.

but the problem is, that the layers with hidden images sometimes are loading too slowly. how can i preload them in this case? maybe it is possible to preload them in variables and them call with a script… ?

i would appreciate any advice. thx ?

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@rootApr 25.2007 — you dont use eval in this way... eval('document.all[id].style.visibility = "hidden"')

document.all[id].style.visibility = "hidden";

is the correct way.

eval is reserved for special occasions like birthdays, christenings and funerals... in other words, you dont use them unless theirs no otherway of creating the element, variable or additional script requirements.
Copy linkTweet thisAlerts:
@Logic_AliApr 26.2007 — hi all,

i have 50 hidden div layers with images insided, each is appr. 200kb big.
[/QUOTE]
50 x 200kb = 10Mb. I can't imagine why they would load slowly.
Copy linkTweet thisAlerts:
@rootApr 26.2007 — With proper treatment, the 200kb images can be compressed to a better "Web Ready" format of around 13kb per picture.

Physical size of the display can be made smaller by resampling to a lower dpi, 72 - 76 dpi is web ready, most photographs on digital cameras is 300dpi, this strips out unneeded bagage in the file.

Physical size of the display can be made smaller by resizing the image from a large pixel size to a smaller size thats going to fit in the site better, why have 1622 pixels when 162 pixels will do?

What I do to pictures is to:-

Resize the image to one thats still large enough to be posted as an enlargement without loss of quality.

reduce the colour bit depths to 256colours, the least you can have to represent a photo on a web page..

reducing the dpi to 72 or 76 dpi will reduce the file size.

Compression ratio of about 70% for a jpg format file, often smaller than gif's

for example, the posted image of 84kb started out as a 405kb image. even at that size, the orginal was almost twice that view size, so reducint the viewable size to 1024x768 along with the compression ratio and colour depth change, stripped out nearly 320kb of excess bagage data that wasnt needed.

The image can be made smaller, by chosing a smaller picture size of about 325x240 will produce an image as small as 17kb.

The original of 405kb is too big to post. So youll have to take my word on it that these 2 pictures are what you can call a good representation with minimal loss in quality.

[upl-file uuid=1f192e95-ff3a-4669-bcd1-6117def29973 size=17kB]DSC00032_20percent@72dpi@[email protected][/upl-file]

[upl-file uuid=f07f215e-259b-4a80-a1e3-476d694e0afa size=84kB]DSC00032_1024x768@72dpi@[email protected][/upl-file]
Copy linkTweet thisAlerts:
@rootApr 26.2007 — Also the images are a common site where I live. NTL MUX boxes broken open.
Copy linkTweet thisAlerts:
@cold_rainauthorMay 01.2007 — ok, man, this is really useful.

but where do i get these dpi's and other "webready" stuff?

i am optimising my pics in image ready, so up to now i have done 110kb from 200kb. and i am looking into file info, and see this:

pixel dimension x: 862 y: 595

resolution x: 72 y: 72

so i already have 72x72 dpi.. ? :rolleyes:
Copy linkTweet thisAlerts:
@rootMay 01.2007 — Y here: http://www.irfanview.com/ and its FREE!
×

Success!

Help @cold_rain spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...