code: function deferClickEvent(evt, anchor, callback){
    var timeout = 500,
        targetAttr,
        cbResponse;
  
    // Get 'target' attribute from anchor
    if (anchor.getAttribute !== void 0) {
      targetAttr = anchor.getAttribute("target");
    } else if (anchor.target) {
      targetAttr = anchor.target;
    }
  
    // Fire listener and catch possible response (return false)
    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;
    }
    // Else if anchor doesn't kick off a new window or tab.. defer and replay the event:
    else if (targetAttr !== '_blank' && targetAttr !== 'blank' && !evt.metaKey && !anchor.hasAttribute('download')) {
      if (evt.preventDefault) {
        evt.preventDefault();
      }
      evt.returnValue = false;
      if (
        anchor.href
        && anchor.href !== '#'
        && anchor.href !== (window.location + '#')
      ) {
        if (typeof cbResponse !== 'undefined') {
          if (navigator && navigator.sendBeacon) {
            window.location = anchor.href;
            return;
          }
          // promise
          cbResponse.then(() => {
            window.location = anchor.href;
          }).catch(err => {
            // change location anyway - to not let user hanging
            window.location = anchor.href;
          });
        } else {
          setTimeout(function(){
            window.location = anchor.href;
          }, timeout);
        }
      }
    }
  
    return false;
  }
docs: ------------------------------ Handle 'click' events (A) ------------------------------