code: function preloader( items, preloadFunction, callback ) {
  
      var itemc = items.length;
      var loadc = 0;
  
      // called by preloadFunction to notify result
      function _check( err, id ) {
          updateProgress(1);
          if ( err ) {
              alert('Failed to load ' + id + ': ' + err);
          }
          loadc++;
          if ( itemc == loadc ) callback();
      }
  
      progressTotalCount += items.length;
  
      // queue each item for fetching
      items.forEach(function(item) {
          preloadFunction( item, _check);
      });
  }
docs: Generic preloader handler, it calls preloadFunction for each item and passes function to it that it must call when done.