News for hackers. Stuff that matters.
Re:Show HN: Minimal Google Analytics Snippet by onion2k on Friday December 14, 2018 @09:02AM (#18680815)
Both of Google's recommended methods of adding Analytics to a website load Google's JS library asynchronously[1]. Including it has no meaningful impact a site's time to first paint or interactivity.

There's a good argument to say loading 70Kb of JS you're not using is a bad idea, and if that's the case then your smaller script is an improvement, but there's also a good argument to say Google Analytics is powerful and useful and maybe you should be using the features that those 70Kb give you in order to improve you site in ways the user would notice. I guess it's down to your specific use case.

[1] https://developers.google.com/analytics/devguides/collection...

Re:Show HN: Minimal Google Analytics Snippet by shift8 on Friday December 14, 2018 @12:02PM (#18682357)
Really good point and I agree. This was intriguing at first glance because who doesn't want less JS on their site?! Of course! However, missing out on other events being tracked, advanced demographic information(?), and what else?? That's a huge miss - especially if you work with Google Ads and have your Analytics linked. Your ad campaigns won't be as effective and could potentially cost more money to save someone an unknown amount of loading time.

This is pretty creative though.

Re:Show HN: Minimal Google Analytics Snippet by dwild on Friday December 14, 2018 @11:07AM (#18681780)
Wouldn't the 70kb would be most likely already cached too? Which make it even more lightweight than this minimal script.
Re:Show HN: Minimal Google Analytics Snippet by dorgo on Friday December 14, 2018 @01:53PM (#18683462)
My firefox never cache anything. Going forth and back in history always reloads the page. That's the reason I have many tabs open - to prevent reloading and waiting.

about.cache says:

Number of entries: 418

Maximum storage size: 30720 KiB

Storage in use: 12698 KiB

Storage disk location: none, only stored in memory

Re:Show HN: Minimal Google Analytics Snippet by tuananh on Monday December 17, 2018 @02:33AM (#18697464)
no because expiration of google analytics is really low (30m or 2h i think)
Re:Show HN: Minimal Google Analytics Snippet by awirth on Friday December 14, 2018 @10:15AM (#18681327)
<script async> does still block the document onload event from firing until it's been executed.
Re:Show HN: Minimal Google Analytics Snippet by scratchnsniff on Friday December 14, 2018 @10:29AM (#18681463)
What about defer?