diff --git a/clientside_validation_jquery/js/cv.jquery.ife.js b/clientside_validation_jquery/js/cv.jquery.ife.js
index bdaf760a485e55d3145ae93947c83f058c9b3d83..51dc9673e99db76a7feb7974de415070f4971efd 100644
--- a/clientside_validation_jquery/js/cv.jquery.ife.js
+++ b/clientside_validation_jquery/js/cv.jquery.ife.js
@@ -5,7 +5,14 @@
 (function ($, once) {
   // Override clientside validation jquery validation options.
   // We do this to display the error markup same as in inline_form_errors.
-  once('cvjquery', 'document').forEach(element => element.on('cv-jquery-validate-options-update', function (event, options) {
+  // Using once can not use `window` or `document` directly.
+  if (!once('cvjquery', 'html').length) {
+    // Early return avoid changing the indentation
+    // for the rest of the code.
+    return;
+  }
+
+  $(document).on('cv-jquery-validate-options-update', function (event, options) {
     options.errorElement = 'strong';
     options.showErrors = function(errorMap, errorList) {
       // First remove all errors.
@@ -23,5 +30,5 @@
         }
       });
     };
-  }));
+  });
 })(jQuery, once);