Skip to content

Instantly share code, notes, and snippets.

@eliperelman
Forked from 140bytes/LICENSE.txt
Last active April 18, 2016 23:20
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save eliperelman/987446 to your computer and use it in GitHub Desktop.
Save eliperelman/987446 to your computer and use it in GitHub Desktop.
Preloader140

Preloader140

A tweet-sized JavaScript Image Preloader.

To use:

var preload = function(a,b){for(a=[].slice.call(arguments),b=a.length;b--;)new Image().src=a[b]}

preload('http://www.google.com/images/logos/ps_logo2.png', 'http://localhost:8080/images/myimage.png', 'image1.jpg')
function (a,b) {
for (
a=[].slice.call(arguments), // make an array of all the supplied string URLs
b=a.length; // cache the length of the array
b--;) // iterate backwards starting with the last URL
new Image().src=a[b] // generate a new image and set its URL, preloading the image
};
function(a,b){for(a=[].slice.call(arguments),b=a.length;b--;)new Image().src=a[b]}
DO WHAT YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Eli Perelman <http://eliperelman.com>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT YOU WANT TO.
{
"name": "Preloader140",
"description": "JavaScript Image Preloader based on 140byt.es rules.",
"keywords": [
"140bytes",
"master",
"image",
"preloader",
"javascript"
]
}
@jed
Copy link

jed commented Jul 11, 2011

hey @eliperelman, would you mind removing the comments from this package.json?

@eliperelman
Copy link
Author

@jed better?

@jed
Copy link

jed commented Jul 11, 2011

awesome, thanks!

@eliperelman
Copy link
Author

No problem, anything I can do to help, let me know!

@jimmywarting
Copy link

huge boost: (...a)=>{for(a of a)new Image().src=a}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment