diff --git a/core/misc/batch.js b/core/misc/batch.js
index f394a55..0af5201 100644
--- a/core/misc/batch.js
+++ b/core/misc/batch.js
@@ -1,4 +1,4 @@
-(function ($) {
+(function ($, Drupal) {
 
 "use strict";
 
@@ -7,28 +7,31 @@
  */
 Drupal.behaviors.batch = {
   attach: function (context, settings) {
-    $(context).find('#progress').once('batch', function () {
-      var holder = $(this);
+    var holder = $(this);
+    var batch = settings.batch;
+    var $progress = $('#progress').once('batch');
+    var progressBar;
 
-      // Success: redirect to the summary.
-      var updateCallback = function (progress, status, pb) {
-        if (progress === '100') {
-          pb.stopMonitoring();
-          window.location = settings.batch.uri + '&op=finished';
-        }
-      };
+    // Success: redirect to the summary.
+    function updateCallback (progress, status, pb) {
+      if (progress === '100') {
+        pb.stopMonitoring();
+        window.location = batch.uri + '&op=finished';
+      }
+    }
 
-      var errorCallback = function (pb) {
-        holder.prepend($('<p class="error"></p>').html(settings.batch.errorMessage));
-        $('#wait').hide();
-      };
+    function errorCallback (pb) {
+      holder.prepend($('<p class="error"></p>').html(batch.errorMessage));
+      $('#wait').hide();
+    }
 
-      var progress = new Drupal.progressBar('updateprogress', updateCallback, 'POST', errorCallback);
-      progress.setProgress(-1, settings.batch.initMessage);
-      holder.append(progress.element);
-      progress.startMonitoring(settings.batch.uri + '&op=do', 10);
-    });
+    if ($progress.length) {
+      progressBar = new Drupal.progressBar('updateprogress', updateCallback, 'POST', errorCallback);
+      progressBar.setProgress(-1, batch.initMessage);
+      progressBar.startMonitoring(batch.uri + '&op=do', 10);
+      holder.append(progressBar.element);
+    }
   }
 };
 
-})(jQuery);
+})(jQuery, Drupal);
