JSFiddle - React, Tailwind, and code Playground

by Michael Russell

JavaScript

_preload = function(url, placeholderUrl) {
    var img = new Image();
    loading = true;
    var placeholder = new Element("img", {
        src: placeholderUrl
    });
    img.placeholder = placeholder;
    img.onload = function(evt) {
        this.placeholder.src = this.src;
        this.placeholder.width = this.width;
        this.placeholder.height = this.height;
        loading = false;
    }
    img.src = url;
    return placeholder;
}

document.body.appendChild(_preload('http://www.psdgraphics.com/file/wave-background.jpg', 'http://github.com/subhaze/mootools-external-favicon/raw/a1ebe87d656737c02e23fd897f7a7169ee895406/me.png'));