How to prefetch and prerender an entire file of images

I have a bunch of images stored in XYZ.com/images/page1

The images are all pretty similar like image1.png, image2.png, etc. So the URL is XYZ.com/images/page1/image1.png

Is there a way to prefetch/prerender all images in the file for a page?

Answers


The following PHP file automatically shows all the images in your folder, and you don’t have to manually update anything, just upload to the folder.

<?php
$folder = 'images/page1/';
$filetype = '*.*';
$files = 

glob($folder.$filetype);
$count = count($files);
echo '<table>';
for ($i = 0; $i < $count; 

$i++) {
echo '<tr><td>';
echo '<a name="'.$i.'" 

href="#'.$i.'">
<img src="'.$files[$i].'" 

/></a>';
echo
substr($files[$i],strlen($folder), strpos($files[$i], '.')-strlen($folder));
echo '</td></tr>';
}
echo '</table>';
?>

HTML5 supports resource pre-fetching which utilizes browser idle time to download or prefetch documents that the user might visit in the near future.

Solution A: You can load the page where all these images are shown:

<link rel="prefetch prerender" href="page1.html">

Solution B: You can cache the images individually:

<link rel="prefetch prerender" href="/images/big.jpeg">
<link rel="prefetch prerender" href="/images/big2.jpeg">
<link rel="prefetch prerender" href="/images/big3.jpeg">

Note: prerender is not a standard attribute but yet is supported by Chrome & IE11+

Learn more here


Need Your Help

PDO Union Count

php mysql pdo

public function totalRecords($keyword) {

Get current cell from =choose functions

excel vba excel-vba

I have a cell with a choose function