title: Load google analytics after page load
body: <p>I develop an web application with preact. The total size of the webapp is about 30KB gzipped (Google Analytics is about 14KB). I want to add google analytics but I dont want that google analytics slows down the initial page load. The recommended method to include analytics.js () is </p>
  
  <pre><code>&lt;!-- Google Analytics --&gt;
  &lt;script&gt; 
      window.ga=window.ga||function(){(ga.q=ga.q|| . 
      []).push(arguments)};ga.l=+new Date;
      ga('create', 'UA-XXXXX-Y', 'auto');
      ga('send', 'pageview');
  &lt;/script&gt;
  &lt;script async src='https://www.google-analytics.com/analytics.js'&gt; . 
  &lt;/script&gt;
  &lt;!-- End Google Analytics --&gt;
  </code></pre>
  
  <p>This works fine, but the analytics.js gets downloaded before my other stuff gets downloaded. Im pretty sure that this affects the page load as you can see in this picture)</p>
  
  <p><a href="https://i.stack.imgur.com/tqSwU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/tqSwU.png" alt="enter image description here"></a></p>
  
  <p>What is the recommend way to download analytics after the page finished loading. (In my case after 'menu' gets downloaded)</p>