Add setting for “Preload resource”
-
This Matomo article recommends adding both of these for better performance:
<link rel="dns-prefetch" href="https://wordpress.org//example.innocraft.cloud">
<link rel="preload" href="https://yourpiwikdomain.com/matomo.js" onload="embedTracker()" type="script" crossorigin>The Connect Matomo plugin currently has a setting on the Expert Settings tab for adding dns-prefetch, but not one for adding preload.
@dizzyatinnocraft could you add a setting to the plugin for adding the preload link too?
I currently have a PHP script I use to add this, but I’d much prefer to have it available directly in the plugin itself.
Incidentally, in the PHP script that I use, I have it looking like this:
<link rel='preload' href='https://my.site.com/js/index.php' as='script' />I remember testing it a few years ago and – for reasons I now forget – concluding that it wasn’t necessary to include “onload=’embedTracker()'” or “crossorigin” in the link, and also changing “type=’script'” to “as=’script'”.
But now I don’t remember why – it might have been that the preload didn’t work anymore, the way it’s written in the Matomo article. I’m hoping you’ll have more expert insight into that!
Lastly: I think it would also be better if both the dns-prefetch and preload links are added as early as possible, at the top of the HTML. Currently, if I turn on the “Enable DNS prefetch” setting on the Expert Settings tab, the link gets added further down in the HTML of the page.
You must be logged in to reply to this topic.