Hi @back2music,
Thank you for your kind words and for using our plugin!
Please note that the tracker script is enqueued using wp_enqueue_script with the $inFooter parameter set to true, ensuring it loads after the HTML content.
This approach naturally delays script execution until the DOM is fully parsed and ready.
As the script is already positioned at the end of the document, adding the defer attribute would not provide any additional performance benefits.
Let us know if you need any further assistance!
Regards,
Matthew
Thank you for the answer!
The diagnostics page https://pagespeed.web.dev suggested me to defer the script execution. Could you explain why they think this is necessary?
Dear @back2music,
As mentioned earlier, we do not add the defer attribute to the script file because it is already loaded in the footer, which ensures that script execution is delayed until the DOM is fully parsed and ready.
We have not received any specific suggestions from PageSpeed Insights for our websites regarding this matter. However, PageSpeed Insights might recommend using defer for extra assurance of non-blocking behavior or to maintain uniformity across scripts.
Could you please share the link to the report so that we can investigate it further?
Thank you!
Regards,
Matthew
Thank you, dear @back2music!
Please note that the WP Statistics JS file is very small and optimized, meaning it won’t have any significant impact on your site’s performance. Additionally, the file is placed in the footer, so it won’t block any content.
However, after further discussion with our team, we’ve decided to implement defer loading strategy for our JS asset. This will be available in an upcoming release.
We appreciate your understanding and patience!
Regards,
Matthew
Dear @back2music,
I’m pleased to inform you that we’ve introduced a new hook in WP Statistics version 14.12.3, allowing you to define the loading strategy for the tracker.js script.
Please update the plugin to the latest version and refer to our guide here: https://wp-statistics.com/resources/modify-tracker-js-loading-strategy/ to adjust the loading strategy accordingly.
Regards,
Matthew
Dear Matthew, thank you very much, it works perfectly!