Step-by-step help to master cookie compliance

Guides

Hero

Download and Host JavaScript Files

Here, you’ll learn exactly how to download the file, host it yourself, and set it up so the banner works smoothly on your site.

Availability

Self-hosting the JavaScript file is available in all paid CookieScript plans.

It is not available on the Free plan.

Why you might self-host

Organizations typically choose to self-host when they:

  • Must store all JavaScript assets on their own domain
  • Want full control over caching or file delivery
  • Prefer avoiding third-party hosted snippets for policy or security reasons

If you don’t have these requirements, the default cloud-hosted script is simpler and updates automatically.

How to download the JavaScript file

  1. Sign in to your CookieScript account.
  2. Open your banner.
  3. Go to Settings → Install.
  4. Scroll to Download and host the banner yourself.
  5. Click Download JavaScript file.

A .js file will download to your computer. You can rename it if you’d like — just remember the exact filename and where you place it, since you’ll reference that path later in your <script> tag.

How to upload the file to your server

Upload the downloaded file to your website using FTP or your hosting provider’s file manager.

You can place it in any directory that fits your setup, for example:

  • /js/
  • /assets/scripts/

Make a note of the precise path, because your website will need it when loading the script.

How to include the file on your website

Once the file is on your server, include it on every page that requires a Cookie Banner. The recommended placement is:

  • Between the and tags
  • Before any other script tags
  • With defer enabled

Example: <script src="/js/Cookie-Script.js" defer></script>

Just replace /js/Cookie-Script.js with the actual path and filename you used when uploading the file.

Important limitations when self-hosting

1. No automatic updates

When you host the JavaScript file yourself, CookieScript cannot update it automatically. Any change you make in your CookieScript account requires you to:

  • Download the updated file again
  • Upload it to your server
  • Replace the old file

This applies to changes in:

  • Banner text, design, and behavior
  • Cookie declaration content

In practice, this also tends to include updates to things like Google Consent Mode v2, IAB TCF 2.2, and third-party script-blocking logic, since all of that logic is part of the same banner script.

To benefit from such updates, you’ll need to download and upload the latest file again. If you prefer automatic updates, use the default cloud-hosted embed.

2. geo-targeting does not work with self-hosted code

geo-targeting requires a visitor IP check on CookieScript servers. Because a self-hosted file bypasses this request, GEO-targeting is disabled. If you need regional display rules, use the standard hosted script.

New to CookieScript?

CookieScript is a full-featured Consent Management Platform (CMP) offering:

In Spring 2025, CookieScript received its fourth consecutive G2 badge for Best Consent Management Platform. It’s also a Google-certified CMP at the Gold tier, showing that it meets the latest requirements for privacy and consent management.

Frequently Asked Questions

How do I self-host a Cookie Banner script on my site?

You can do that by downloading the banner’s JavaScript file from your account. CookieScript provides a self-hosting option in all paid plans, so you can upload the file to your own server and load it directly from there.

How do I self-host a cookie banner script on my site?

You can do that by downloading the banner’s JavaScript file from your account. CookieScript provides a self-hosting option in all paid plans, so you can upload the file to your own server and load it directly from there.

Can I manually download the cookie banner script?

Yes. CookieScript lets you download the JavaScript file from the Install section of your banner settings, which you can then host on your own server.

Am I allowed to rename the Cookie Script after downloading it?

Yes. CookieScript doesn’t require a specific filename—just make sure your <script> tag points to the name and location you choose.

Do I have to re-upload the file after I change my banner settings?

Yes. With a self-hosted setup, CookieScript can’t refresh the file on your server, so any updates you make in your banner settings require a new download and upload.

Where should I add the Cookie Script tag in my HTML?

The recommended placement from CookieScript is inside the <head> section, before any other scripts. This ensures proper consent handling and script-blocking.

Will Consent Mode v2 still work if I host the script myself?

It will, but only if you keep the file current. CookieScript updates its Consent Mode v2 logic over time, so you’ll want to upload the newest version when changes are released.

Does third-party script blocking still function when I self-host the banner file?

Yes. CookieScript still blocks third-party scripts based on user consent. When improvements or fixes are released, they become active after you upload the latest version of the JavaScript file.

Could hosting the Cookie Script myself affect page speed?

It can. CookieScript allows self-hosting so you can control caching and delivery, which may improve performance depending on your server setup.

Can I use self-hosting on the free plan?

No. CookieScript includes the self-hosted JavaScript option only in paid plans. The free plan uses the standard hosted embed.

Will self-hosting change how my cookie banner works?

No. The banner still delivers the same features—Consent Mode v2, IAB TCF 2.2 support, consent logs, and cookie scanning—when the CookieScript file is kept updated.

New to CookieScript?

CookieScript helps to make the website ePrivacy and GDPR compliant.

We have all the necessary tools to comply with the latest privacy policy regulations: third-party script management, consent recording, monthly website scans, automatic cookie categorization, cookie declaration automatic update, translations to 34 languages, and much more.