- How does Hotjar's script affect page load?
- Could Hotjar affect my site's performance?
- Why does Google Page Speed test tell me my site is slow with Hotjar?
How does Hotjar affect page load?
We take all the necessary steps in ensuring fast deliverability of our service on your sites with as little impact as possible. Here's how:
- The script is loaded asynchronously. This means that the Hotjar script does not stop your site from loading its own assets.
- The script is served through a Content Distribution Network (CDN). The Hotjar script is served to your visitors from a system of strategically positioned servers around the globe, rather than from a single location. This allows the script to be loaded faster by your visitors while offering much better availability. We currently average 130 - 200ms globally.
- The script makes proper use of browser cache. Although the script loads asynchronously, it is still important to get the script loaded and running as fast as possible when tracking visitors. We do this by making the best use of browser cache by loading two separate files which are reloaded by browsers at different intervals or when changed. These files, together with all other requests we do, are explained in Hotjar Requests.
Could Hotjar affect my site's performance?
In terms of usage tracking, Hotjar does primarily two separate things:
- At regular short intervals, every 100ms or 10 times per second, the cursor position and scroll position are recorded. Clicks are recorded when they happen, capturing the position of the cursor relative to the element being clicked. These functions do not affect a user's experience as they only capture the location of the pointer when a click happens or every 100ms. The events are sent to the Hotjar servers through frames within the websocket. This method is more efficient than sending XHR requests at regular intervals.
- When it comes to Recordings, changes to the page are captured using the MutationObserver API which is built-in into every modern browser. This makes it efficient since the change itself is already happening on the page. The browser MutationObserver API allows us to record this change which we then parse and also send through the websocket.
Why does my page speed test tell me my site is slow with Hotjar?
Tests such as Google's PageSpeed can tell you a lot about how your page loads. We recognize how important it can be to understand and optimize page-load in this way. It is important to understand what these reports tell you, and what is or isn't an issue that needs to be resolved.
If we need to review the speed of your page, our support team will use webpagetest.org. The reports from webpagetest.org will show you when the page was interactive for users and when the document load has been completed. Here's an example of a page without the Hotjar tracking code.
This page is interactive at around 0.4 seconds and completes loading in around 1 second.
This is the same page with a Hotjar tracking code added:
The page is interactive at just over 0.4 seconds and completes loading at just under 1.3 seconds. In this instance, we can see that the initialization of Hotjar has had a minimal impact on the page being usable (around 0.01 seconds) and has added around 0.3 seconds to the overall page completion.
Hotjar script loads asynchronously in two parts, with the first part containing the settings for your site. In the image above this loads at Step (3). The rest of the content for the site then loads (4-6) before the Hotjar script resumes downloading (7).
Depending upon the specific Hotjar tools you have set up and which pages are being targeted, it opens up a web socket and begins sending information back to our servers. Your site has usually finished loading while this process happens in the background.
When a tool like the Google Page Speed Test measures a site with Hotjar installed, it includes the time that Hotjar takes to request the full batch of modules from our servers, as well the time we start to send data back. This is an inaccurate picture of your site's speed because your site has finished loading and Hotjar is only sending back analytics data.