> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/feature-management-experimentation/new-to-fme/sdks-and-customer-deployed-components/examples/javascript-wordpress-site.md).

# Deploying the JavaScript SDK to a WordPress Site

### Overview <a href="#overview" id="overview"></a>

This page walks you through using the JavaScript SDK on a blank page within a Wordpress site by embedding the SDK scripts and code directly.

### Step 1: Install the Header and Footer Scripts Plugin (recommended) <a href="#step-1-install-the-header-and-footer-scripts-plugin-recommended" id="step-1-install-the-header-and-footer-scripts-plugin-recommended"></a>

While not strictly required, it is a good practice use a plugin such as **Header and Footer Scripts** to manage JavaScript loaded in the page header.

![](/files/WDKRNQcVdQHkGgP5jBCj)

### Step 2: Create a Sample Page <a href="#step-2-create-a-sample-page" id="step-2-create-a-sample-page"></a>

Create or open a page in WordPress where you want to deploy the SDK.

![](/files/idQ1f4Rs3mAI7GTmQXPV)

### Step 3: Insert the SDK Script Tag in the Header <a href="#step-3-insert-the-sdk-script-tag-in-the-header" id="step-3-insert-the-sdk-script-tag-in-the-header"></a>

In the page editor, scroll to the bottom and locate the **Insert Script to \<Head>** section provided by the plugin. Paste the following script tag there to load the SDK library:

```html
<script src="https://cdn.split.io/sdk/split-10.21.1.min.js"></script>
```

![](/files/vqnwXX6EduuZkLCChOVJ)

### Step 4: Add Custom HTML Block with SDK Initialization Code <a href="#step-4-add-custom-html-block-with-sdk-initialization-code" id="step-4-add-custom-html-block-with-sdk-initialization-code"></a>

Click the **+** sign to add a new block and select **Custom HTML**.

![](/files/i4yIJI43B3e5sksvd3TB)

In this block, paste the following JavaScript, replacing the placeholders with your actual API key, user key, and feature flag name:

```html
<p id="sdk"></p>
<script>
factory = splitio({ core: {
 authorizationKey: 'SDK API KEY',
 key: 'USER KEY',
 },
 startup: {
 readyTimeout: 4, requestTimeoutBeforeReady: 4
 },
});
client = this.factory.client();
client.on(client.Event.SDK_READY, () => {
 treatment = client.getTreatment("SPLIT NAME");
 console.log("treatment = "+treatment);
 var pobj = document.getElementById("sdk");
 pobj.innerHTML = "<p>Split: [SPLIT NAME], Treatment = "+treatment+"</p>";
});
</script>
```

### Step 5: Save and Preview <a href="#step-5-save-and-preview" id="step-5-save-and-preview"></a>

Save the page and open it in your browser. Once the SDK signals it is ready (the `SDK_READY` event), it will fetch the feature flag treatment and display the result inside the \`\` element with id `"sdk"`.

![](/files/80y1Z5dxhSgagpAOdp8F)

This approach allows you to run the JavaScript SDK on any WordPress page without modifying the theme or server files.
