At Hotjar we take site performance very seriously and do everything in our power to optimize everything in the process. Hotjar's script, like most scripts and other tracking solutions, will only have a marginal, almost negligible, effect on your site's speed and performance.
In Hotjar's case, we take all the necessary steps in ensuring fast deliverability of our service on your sites with as little impact as possible. Here is how:
- The script is loaded asynchronously. This means that 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, and not 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 here.
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 are functions which in no way hinder 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, which 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 and the browser MutationObserver API allows us to record this change which we then parse and also send through the websocket.
Why does Google Page Speed test tell me my site is slow with Hotjar?
Unfortunately, this type of measuring tool doesn't always give an accurate picture when tracking scripts like Hotjar.
The Hotjar script loads asynchronously and in two parts, with the initial part containing the settings of your site, and the second part containing the modules that allow us to track data. Then, 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 only Hotjar sending back analytics data.