code: function loadImage(url, callback, error) {   
      var img = new Image();
      img.src = url; 
      if(img.complete){
        return callback(img);
      }
      img.onload = function(){
        img.onload = null;
        callback(img);
      };
      img.onerror = function(e){
        img.onerror = null;
        error(e);
      };  
    }
docs: 图片预加载