code: function deferFormSubmit(evt, form, callback){
    var timeout = 500;
    // Fire listener and catch possible response (return false)
    var cbResponse = callback(evt);
  
    // If prevented within callback, bail
    if (('boolean' === typeof cbResponse && cbResponse === false) || evt.defaultPrevented || evt.returnValue === false) {
      if (evt.preventDefault) {
        evt.preventDefault();
      }
      evt.returnValue = false;
      return false;
    }
    // Defer and replay event
    else {
      if (evt.preventDefault) {
        evt.preventDefault();
      }
      evt.returnValue = false;
      if (typeof cbResponse !== 'undefined') {
        if (navigator && navigator.sendBeacon) {
          form.submit();
          return;
        }
        // promise
        cbResponse.then(() => {
          form.submit();
        }).catch(err => {
          // submit form anyway - to not let user hanging
          form.submit();
        });
      } else {
        setTimeout(function(){
          form.submit();
        }, timeout);
      }
    }
  
    return false;
  }
docs: ------------------------------ Handle 'submit' events (FORM) ------------------------------