From: gc Date: Sun, 6 Mar 2005 18:35:11 +0000 (+0000) Subject: don't preload all images, only ahead of 5 images and backward of 3 images X-Git-Tag: 0.9.0~713 X-Git-Url: http://git.zarb.org/?p=booh;a=commitdiff_plain;h=02eaf3d0a294c0b6f89b0b4e3cd8288b65d02c14 don't preload all images, only ahead of 5 images and backward of 3 images --- diff --git a/html_merges.rb b/html_merges.rb index 4632fe4..c5212b5 100644 --- a/html_merges.rb +++ b/html_merges.rb @@ -75,22 +75,25 @@ function preload() { * but rather load them one by one, in order to get * next ones faster, beginning with next to current */ - for (i = current + 1; i < images.length; i++) { + for (i = current + 1; i < images.length && i <= current + 5; i++) { if (load(i) == 0) { setTimeout("preload()", 500); return; } } - for (i = 0; i < current; i++) { - if (load(i) == 0) { - setTimeout("preload()", 500); - return; + for (i = current - 1; i >= current - 3; i--) { + if (i >= 0) { + if (load(i) == 0) { + setTimeout("preload()", 500); + return; + } } } + + setTimeout("preload()", 500); } function init() { - preload(); /* retrieve GET parameters */ all_params = location.href.split("?") @@ -115,6 +118,7 @@ function init() { } } + preload(); display_current(); }