How does TrueVault JS impact my website loading time?
The TrueVault script should be added to the <head> element of your business's website. It must be the first functional script since it determines the users consent settings before any other scripts are run on your site.
Being the first functional script the load time is very important to TrueVault and we optimize it to be as fast as possible. There are 2 paths the script takes when loading.
First page load (~75ms):
- Download
polaris.jsfrom the CDN - Determine users location by making a request to https://location.truevaultcdn.com. This uses a AWS Lambda and CloudFront headers to determine the location of the user.
- Initialize local cookies to store user opt outs.
- Perform Third-Party opt-out where applicable such as Google Analytics.
- Show or hide relevant links based.
Subsequent page loads (~10-20ms)
- Load
polaris.jsfrom the local cache. - Load local cookies to determine user opt outs.
- Perform Third-Party opt-out where applicable such as Google Analytics.
- Show or hide relevant links based.
Can I load polaris.js with async or defer?
No. Load polaris.js synchronously (no async or defer attributes), before Google Tag Manager and any other script that requires consent. Several protections only work if Polaris runs before the rest of the page:
- Consent state comes first. Polaris establishes the visitor's consent state — including a returning visitor's stored choice — and emits the initial
consentChangedevent before other scripts run, so everything downstream starts from the correct state. - Blocking directly installed scripts. Scripts gated with
data-polaris-consentare blocked by a watcher Polaris installs at startup. If Polaris loads withasyncordefer, scripts that appear earlier in the document can execute before the watcher exists. - Vendor opt-outs that must be set before the vendor loads. Signals like the Google Analytics
ga-disableflag only take effect if they are in place before the vendor's snippet runs.
Loading Polaris with async or defer removes these guarantees: consent-gated scripts can fire before the visitor's choice is applied. The synchronous cost is small by design — roughly 10–20ms on cached page loads, as described above.
If you have other questions please reach out to help@truevault.com and our engineering team will be happy to provide more insights.