<a href="https://www.google-analytics.com/analytics.js" download="file">download the google analytics javascript file with a tag </a>

<hr>

<button>download with blob</button>

function downloadFile(url, fileName){
  fetch(url, { method: 'get', mode: 'no-cors', referrerPolicy: 'no-referrer' })
    .then(res => res.blob())
    .then(res => {
      const aElement = document.createElement('a');
      aElement.setAttribute('download', fileName);
      const href = URL.createObjectURL(res);
      aElement.href = href;
      // aElement.setAttribute('href', href);
      aElement.setAttribute('target', '_blank');
      aElement.click();
      URL.revokeObjectURL(href);
    });
};
document.querySelector('button').onclick =function () {
  downloadFile('https://www.google-analytics.com/analytics.js', 'gooleAnalytics.js');
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.