function checkFileExists(url) {
  const http = new XMLHttpRequest();
  http.open('HEAD', url, false);
  try {
    http.send();
  } catch (_e) {
    return false;
  }
  return http.status != 404;
}
Check whether or not a JS file exists at the url specified.
@param {string} url The url of the file.
@returns {boolean} Whether or not the file exists.