It's hard to analyze more than page views using only webserver logs. I might be interested in some specific user behavior (e.g. how much times he clicked this button, etc.). That's why we have to put a js script.
Let's have a simple case. How are you going to analyze how much times a user clicked a button? I don't want to reload the page on each click (to send a GET request) and AFAIK there's no way to do that without JS. And if I can use JS for that case, why would I want to do that if I can simply myTracker.send({'action': 'my-button.click', ...})?
If that button does anything relevant, it's going to leave evidences on your server anyway. Theoretically, we don't really need JS to reload a subset of a page on a button click: HTML and CSS are enough, with proper uses of IFRAME.
However you are right that, if you are using JS anyway, a bit more bloat doesn't change much.
The point is that we shouldn't use JS just because it exists, but only if there's something we cannot really do otherwise. Forcing our users to execute code we didn't write and we don't feel responsible for is rude: we are wasting their resources (and potentially compromising their security) just to save some money.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It's hard to analyze more than page views using only webserver logs. I might be interested in some specific user behavior (e.g. how much times he clicked this button, etc.). That's why we have to put a js script.
You don't need js for that, a querystring is enough.
Not really. What about SPAs?
Let's have a simple case. How are you going to analyze how much times a user clicked a button? I don't want to reload the page on each click (to send a GET request) and AFAIK there's no way to do that without JS. And if I can use JS for that case, why would I want to do that if I can simply
myTracker.send({'action': 'my-button.click', ...})
?It's quite obvious that if you are using JS anyway, a little more bloat doesn't change much.
However there is often no reason to use JS and plenty of reasons to NOT execute third party's code on your users' machines if you care about your users' privacy and security.
If that button does anything relevant, it's going to leave evidences on your server anyway. Theoretically, we don't really need JS to reload a subset of a page on a button click: HTML and CSS are enough, with proper uses of IFRAME.
However you are right that, if you are using JS anyway, a bit more bloat doesn't change much.
The point is that we shouldn't use JS just because it exists, but only if there's something we cannot really do otherwise. Forcing our users to execute code we didn't write and we don't feel responsible for is rude: we are wasting their resources (and potentially compromising their security) just to save some money.