Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexrabarts/jquery-cacheimage
A simple jQuery plugin for pre-caching images.
https://github.com/alexrabarts/jquery-cacheimage
Last synced: 16 days ago
JSON representation
A simple jQuery plugin for pre-caching images.
- Host: GitHub
- URL: https://github.com/alexrabarts/jquery-cacheimage
- Owner: alexrabarts
- Archived: true
- Created: 2008-12-22T06:07:48.000Z (almost 16 years ago)
- Default Branch: master
- Last Pushed: 2013-09-11T18:58:23.000Z (about 11 years ago)
- Last Synced: 2024-08-01T00:57:10.560Z (3 months ago)
- Language: JavaScript
- Homepage: http://github.com/alexrabarts/jquery-cacheimage
- Size: 114 KB
- Stars: 39
- Watchers: 5
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
# cacheImage: a jQuery plugin
cacheImage is a simple jQuery plugin for pre-caching images. The
plugin can be used to eliminate flashes of unstyled content (FOUC) and
improve perceived page load time. Callbacks for load, error and abort
events are provided.## Usage
Cache an image:
$.cacheImage('/path/to/image.png');
// or if you have images hidden in the DOM:
$('#myImage').cacheImage();Cache several images:
$.cacheImage(['/path/to/an/image.png', '/path/to/another/image.png'])
// or if you have images hidden in the DOM:
$('#myImages img').cacheImage();Add some callbacks:
$.cacheImage('/path/to/image.png', {
load : function (e) { console.log('Loaded', this, e); },
error : function (e) { console.log('Error', this, e); },
abort : function (e) { console.log('Aborted', this, e); },
// complete callback is called on load, error and abort
complete: function (e) { console.log('Completed', this, e); }
});# Licensing
Licensed under the MIT:
http://www.opensource.org/licenses/mit-license.phpCopyright (c) 2011 Stateless Systems (http://statelesssystems.com)