Skip to content

Instantly share code, notes, and snippets.

@chrism
Created May 26, 2015 15:21
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save chrism/c35756037f5feaac5023 to your computer and use it in GitHub Desktop.
Save chrism/c35756037f5feaac5023 to your computer and use it in GitHub Desktop.
Preloading images using Ember.JS util
import Ember from 'ember';
var Promise = Ember.RSVP.Promise;
export default function preloadImages(...urls) {
let promises = urls.map(url => {
return new Promise((resolve, reject) => {
let image = new Image();
image.onload = resolve;
image.onerror = reject;
image.src = url;
});
});
return Promise.all(promises);
}
@drewbaker
Copy link

How did you get around Ember fingerprinting the files in production? Were all your files on a CDN, and thus not finger printed?

@filipecrosk
Copy link

Thanks for sharing, I added this to my app and works great :)

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