> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kameleoon.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Application file self-hosting with Cloudflare CDN

> Self-host the Kameleoon application file on Cloudflare CDN to reduce DNS latency and SSL handshake overhead compared to using the default Kameleoon CDN.

<Info>
  `kameleoon.js` is deprecated and has been replaced by `engine.js` in all Kameleoon implementation snippets. `kameleoon.js` will no longer be supported after **June 1st, 2026**. After this date, any campaigns on websites still referencing `kameleoon.js` will stop functioning. Update your implementation snippet accordingly.
</Info>

## Setting up a worker in Cloudflare[​](#setting-up-a-worker-in-cloudflare "Direct link to Setting up a worker in Cloudflare")

Log in to your Cloudflare account and create a worker to point the original request back to your Kameleoon Web Experimentation snippet. You will need to configure the necessary Cloudflare **route** and **script**.

### Route[​](#route "Direct link to Route")

Add the following path: `*<your_website_url_here>/kameleoonjs/script.js`.

### Script[​](#script "Direct link to Script")

You need a script that listens for requests from the `/enginejs/` route and replaces that route with the one that leads to your Kameleoon snippet.

You can use the script below, where `YOUR_SITECODE` must be replaced with your Kameleoon Project ID (follow the steps outlined in this [article](/user-manual/faq#how-do-i-find-my-sitecode) to retrieve it).

```js theme={null}
async function handleRequest(request { 
   const url = "https://YOUR_SITECODE.kameleoon.xx/engine.js";
   return fetch(url)
}

addEventListener('fetch', event => {
   event.respondWith(handleRequest(event.request))
})
```

<Warning>
  The domain for your Kameleoon scripts (https\://\[your-site-code].kameleoon.xx) may vary from one project to another. Your projects may be hosted on either kameleoon.eu or kameleoon.io, depending on their creation date. Ensure you use the domain displayed in your project in the Kameleoon app.
</Warning>

## Add the Kameleoon snippet in your source code[​](#add-the-kameleoon-snippet-in-your-source-code "Direct link to Add the Kameleoon snippet in your source code")

<Note>
  Refer to this [article](../implementation-and-deployment/standard-implementation) to understand how to implement Kameleoon on your website.
</Note>

The final step is to replace the default Kameleoon Application JavaScript URL in the installation tag with your Cloudflare URL (eg. `<your_website_url_here>/kameleoonjs/script.js` if you have chosen this **route**). For instance, if you are using the JavaScript File ([Asynchronous Loading with Anti-Flicker](../implementation-and-deployment/standard-implementation#asynchronous-tag-without-anti-flicker)) implementation method, the Kameleoon application file is by default hosted on `//SITE_CODE.kameleoon.io/engine.js`. You just need to change this URL in the installation tag, replacing it with your own URL.
