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
<!-- Google Analytics -->
ga('create', 'UA-XXXXX-Y', 'auto');
<script async src='https://www.google-analytics.com/analytics.js'> .
<!-- End Google Analytics -->
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)
What is the recommend way to download analytics after the page finished loading. (In my case after 'menu' gets downloaded)