Matomo tracker affecting website performance

We have a small website getting about 90K users per day and are hosting Matomo (v4.14.2) for analytics data. We’ve been using the default JavaScript tracking code as given by our Matomo install, store it in a separate .js file and load the file near the end of the page contents (but inside the body tag). Due to technical constraints we cannot change how the script is loaded.

We recently had an issue when our Matomo server became unavailable because of incorrect network configuration. This also caused performance issues on our website when the browser tried to load URLs from the Matomo server and waited until the request timed out, resulting in 20-120 second delays before the page contents were fully loaded and visible to the user.

Looking at this post from '19 Matomo Performance (Page Speed) it sounds like Matomo being slow shouldn’t slow down our website, as it should be loaded asynchronously and deferred, but this is not what we observed when our Matomo server was unreachable.

When searching for solutions how to avoid this issue in the future I came upon this blog post Different ways of embedding the Matomo tracking code for faster website performance - Analytics Platform - Matomo and embedding the tracker after the load event as recommended here seemed to solve the issue.

Since this blog was written in 2017 I wanted to ask the community if this is still the recommended way to make sure Matomo being slow/unavailable doesn’t affect the main website performance?

Even if you are loading the script (which then loads the matomo-code) at the end of the page, this loading will block your webpage if you are not loading it asynchronously. I’m not sure if there is a solution if you are not able to change the code from:
<script src="/my-matomo-script.js">
to
<script src="/my-matomo-script.js" async>

I think the best way would be if you become somehow able to insert the original matomo-code-snipped to your webpage. With that, we got all “green” in Google Page Speed for example.

Thanks. I don’t think we’re able to do either of those though. The only way we can easily get the tracking code to every page of our website is to add a <script="/my-matomo.js"> inside the <body> of the html page, and since we do not have full source control of the website engine we use the way we do it unfortunately doesn’t allow us to control the location of the script tag nor add the async attribute.

That’s why I was looking into embedding tracker after the load event. I know this may affect the way we track our users, but that’s still better than blocking the page loading completely.

Any other suggestions that work by modifying the tracking code snippet are welcome.