Delayed loading of Matomo or Tag Manager / load on consent

Hello everyone.

I think the general suggestion is to load the Matomo / Tag Manager script as early as possible?
However, I didn’t find any information about why that is.
What would be the side effects of a delayed loading of the Matomo script?
What I would like to do is to just load Matomo after the crucial assets for my page loaded.

Some side effects I might think of:

  • As far as I know Matomo tracks page load time? That would not be possible anymore I guess.
  • Custom events pushed to _paq or _mtm should be picked up and transferred to the server once the tracker loaded, right? So that should be fine.
  • However, is Matomo timestamping everything that gets pushed to _paq and _mtm? This would obviously not happen before Matomo loaded, so timestamps would be off?
  • The Tag Manager integration script sets a mtm.startTime. What is it for? Should I set this value manually as soon as possible even if the script will be loaded later?
  • Obviously all tracking set up in the tag manager will not be active until the script is loaded.

Another use case for loading the Matomo script delayed is to only load it on user consent. If the user has not given consent, the script would thus not be loaded at all.
However, the suggested way of handling consent in Matomo is to always load the script and use _paq.push(['requireConsent']); together with _paq.push(['setConsentGiven']); (JavaScript Tracking Client: Integrate - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3). Why is that?
What’s the upside of doing this (if I want to do consent handling manually, i.e. not using rememberConsentGiven?)
Might Matomo be caching all prior events and send them at once when calling setConsentGiven such that no information would be lost? If so, does it also do that between multiple page (re)loads and navigations before consent is given or only for the currently loaded page?
A similar effect can be archieved by just pushing my custom events to _paq and _mtm though for the current page session.

Can somebody help me understand this?
Unfortunately I didn’t find any information regarding this.

Thank you very much in advance.