Currently, I am using WP Super Cache plugin which is great for generating static html pages and preloading images from the database, but I have a large background image and other small icons in my theme directory in an images folder that I’m using jQuery Load CSS Images for.
<?php if ( is_home() ) { ?>
<script src="<?php bloginfo('template_directory'); ?>/scripts/preload.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery.preloadCssImages();
});
</script>
<?php } ?>
The script searches then preloads img src tags and I was wondering if there is a jQuery plugin that can just preload my theme’s image folder once. The if ( is_home() ) statement works to an extent, but will still load multiple times. Was wondering if there is a way to do so just once, maybe by detecting if images are already loaded?
Any suggestions would be greatly appreciated.
I think this script was intended to download additional images not downloaded by the initial page load. Because of the document.ready() function this will not execute until the document is fully loaded. So any CSS images needed for the initial view are already downloaded. I think it was intended to preload images not yet used by the DOM. Example – rollover or hover background changes.
Also if you have you cache headers set correctly the images should not be downloaded multiple times. It will be called from cache if the user has not disabled caching.
Google mod_pagespeed is a great way to extend cache headers.