Hey there! So, you’re worried that adding more scripts (like the one for GA4) could slow down your page? No need to stress about it, it’s a common misconception. The reality is, these small, non-blocking scripts like gtag usually don’t really affect your page load time in a noticeable way when loaded asynchronously.
Now, if you’re into keeping things neat, you might want to look into using something like Google Tag Manager or another tag management system. They’re designed to handle this kind of stuff, only loading scripts as they’re needed. It’s kind of like having one ring to rule them all, without the whole destroy-the-world thing.
And, just a little food for thought, if loading scripts is a big concern, have you considered not loading the analytics.js at all? You could include everything directly in your source or even rewrite everything to send data directly through the measurement protocol. This would apply to GA4 as well. All these libraries do is make the process of sending network requests to their endpoint easier to manage. Just a thought!