Piwik and http/2

Hello community,

I have a question: I am using piwik on my server that works with http/2 support, so I can load all js and css files in parallel.
The standard js tracking code of piwik goes to the head and has g.async=true; g.defer=true; added for non render-blocking loading of piwik.

Though that I use http/2 I don’t care about number of requests but I care of loading time of website and the actual tracking code slows down the loading time.

How can I insert the piwik code render-blocking the “old way” ?

Do I have to put g.async=false; g.defer=false; in it and insert the js in the footer ?
Or do I have to use another code snippet than the actual tracking code to load piwik render-blocking ?

Many thanks for your help…

Best Regards,

Noone here who knows the answer ?

I am not sure I understand your question.

While the number of requests doesn’t matter as much with http/2, the number of piwik requests is always the same no matter how you embed the tracking code. It always needs to fetch piwik.js and then send the data to piwik.php.

Setting the script as async and defer doesn’t slow don’t the loading, if anything it speeds it up, as it waits until the page has finished loading and the user can interact with the website and only then starts loading piwik.

Am I misunderstanding something?

Hi findus23,

many thanks for your reply.
I think you misunderstood me a bit. I will try to explain it in other words:

when I start a websitetest on my site www.ballonkuenstler.biz on pingdom tools:
Website speed test

The thing that slows my loading speed down is piwik. I thought it is because of the async and defer oprion.

Therefore I asked if it is possible to load the js of piwik synchronious. Because I have http/2 enabeled I can load all js and css in parallel rather than one by one like the old http 1.1

Is it clearer now ?

I think the visualization of pingdom is a bit vague, as it doesn’t show when the site is rendered (and the user can start reading)

While async/defer does technically result in a longer time until all files have loaded, that doesn’t mean the user needs to wait for a longer time.

On the other hand if you disable async/defer and load piwik (and google analytics, as the same is valid for them) synchronous, the browser will wait until piwik has finished loading before it will show the user the website. (So they need to wait longer)

You can test this in the Chrome (or Firefox) Developer Tools if you enable throttling.

(BTW: In my opinion, your site is already pretty fast. Especially if one considers the load time of most other webpages. Just a few weeks ago I had a discussion with the support of the largest webhoster in Austria, who thought it was completely normal, that the initial HTTP request (fetching HTML) takes more than a second.)

1 Like