_scriptLoadHandler(el, done) {
    function cleanup() {
      el = el.onload = el.onreadystatechange = el.onerror = null;
    }

    const error = this.options.error;

    function success() {
      cleanup();
      if (done != null) {
        done();
      }
      done = null;
    }

    function failure(err) {
      cleanup();
      error(err);
      if (done != null) {
        done();
      }
      done = null;
    }

    function reattachEventListener(el, evt) {
      const handler = el[`on${evt}`];
      if (handler != null) {
        el[`_on${evt}`] = handler;
      }
    }

    reattachEventListener(el, 'load');
    reattachEventListener(el, 'error');

    Object.assign(el, {
      onload() {
        if (el._onload) {
          try {
            el._onload.apply(this, Array.prototype.slice.call(arguments, 0));
          } catch (err) {
            failure({msg: `onload handler failed ${err} @ ${el.src}`});
          }
        }
        success();
      },

      onerror() {
        if (el._onerror) {
          try {
            el._onerror.apply(this, Array.prototype.slice.call(arguments, 0));
          } catch (err) {
            failure({msg: `onerror handler failed ${err} @ ${el.src}`});
            return;
          }
        }
        failure({msg: `remote script failed ${el.src}`});
      },

      onreadystatechange() {
        if (/^(loaded|complete)$/.test(el.readyState)) {
          success();
        }
      }
    });
  }
Setup the script load handler on an element.

@param {Object} el The element
@param {Function} done The callback
@private