This function will preload all the files contained in one directory into the browser's cache memory. I used the public directory so the program should run on any RB server.
'*******************************************************************
'
'  Preload images in browser's cache for greater speed
'
'********************************************************************
ImgDir$ = "public\"
result=Preload(ImgDir$)
if result=1 then print "No files found in ";ImgDir$
 
wait
 
'********************************************************
' PRELOAD FUNCTION
' returns 0 for success and 1 for empty directory
'********************************************************
Function Preload(dirname$)
   files #g, dirname$+ "*.jpg"
   if #g HASANSWER() then
      count = #g rowcount()
      for i = 1 to count
         if #g hasanswer() then
            dummy$ = #g nextfile$()
            photo$=#g NAME$()
            print "- Loading ";photo$
            html "<script type='text/JavaScript'>"
            html "var photo = new Image();"
            html "var photoname='"+photo$+"';"
            html "photo.src=photoname;"
            html "</script>"
          end if
      next
      preload=0
   else
      preload=1
   end if
End Function