- 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 to ensure the fast deliverability of our service on your sites with as little impact as possible. Here's how:
The script is loaded asynchronously.
The Hotjar script does not stop your site from loading its assets because the script is loaded asynchronously.
We use a Content Distribution Network (CDN) to serve the Hotjar script.
A system of strategically positioned servers around the globe serves the Hotjar script rather than from a single location. Using a CDN allows the Hotjar script to be loaded faster by your users while offering much better availability. We currently average 130 - 200ms globally.
The script makes proper use of browser caching.
Although the script loads asynchronously, it is still important to load and run the script as fast as possible when tracking users. We do this by making the best use of the browser cache and loading two separate files which are reloaded by browsers at different intervals or when changed. These files and all other requests we do are explained in our Hotjar Requests article.
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 ten times per second, the cursor position and scroll position are recorded. Clicks are recorded when they happen, capturing the cursor's position relative to the clicked element. 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.
- For Recordings, changes to the page are captured using the MutationObserver API, which is already included in 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 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 the importance of understanding and optimizing page load in this way. It is essential 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 was 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 about 1 second.
Below is the same page with the 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 added about 0.3 seconds to the overall page completion.
Hotjar's 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 through steps 4-6, before the Hotjar script resumes downloading at step 7.
When tools like Google Page Speed Test measure a site with Hotjar installed, they include the time Hotjar takes to request the entire batch of modules from our servers, and the time we start to send data back. This is an inaccurate picture of your site's speed because your site will have finished loading and Hotjar is only sending back analytics data.