Works with any backend npm install Zero dependencies

Retry with Backoff Strategy

Compare linear vs. exponential backoff strategies for failed upload retries.

(function() {
 var logEl = document.getElementById('log');
 function log(m) { var d = document.createElement('div'); d.className='pkg-log-entry'; d.textContent=m; logEl.appendChild(d); logEl.scrollTop=logEl.scrollHeight; }
 new MultipleUpload('#demo', {
 uploadUrl: '/api/upload',
 multiple: true,
 retries: 3,
 retryDelay: 1000,
 retryBackoff: 'exponential',
 onTaskRetry: function(task) {
 var delay = 1000 * Math.pow(2, task.retryCount - 1);
 log('Retry #' + task.retryCount + ' for ' + task.fileName + ' after ~' + delay + 'ms');
 },
 onTaskError: function(task, err) {
 log('Failed: ' + task.fileName + ' - ' + err);
 }
 });
})();

Spacing the attempts out

retryBackoff defaults to 'exponential' and retryDelay to 1000 ms, so retries wait roughly 1s, then 2s, then 4s rather than hammering a server that has just failed.

Why the delay is the point

Most upload failures are transient and caused by something that needs a moment: a connection dropping as a phone changes network, a server briefly overloaded. Retrying immediately reproduces the same failure and adds load to whatever caused it. Backing off gives the condition time to clear, which is why the slower strategy succeeds more often than the fast one.

maxRetries is the legacy alias for retries, applied only when retries is absent.