function loadScript(file) {
  return new Promise((resolve, reject) => {
    const script = /** @type {!HTMLScriptElement} */(
      document.createElement('script'));
    script.defer = false;
    script['async'] = false;
    script.onload = resolve;
    script.onerror = reject;
    script.setAttribute('src', '/base/' + file);
    document.head.appendChild(script);
  });
}
Load a script dynamically and await completion.

@param {string} file
@return {!Promise}