Add Script Management to help reduce the poor performance that certain JavaScripts can cause for your site. Use it to gather metrics information on script usage and then build a policy to block or defer problematic scripts. It doesn't apply to embedded script elements in your site's pages. It only affects referenced scripts—external script resources that require a separate request.

Follow this tutorial walks to add Script Management to your Ion property.

📘

Make sure you've completed everything in Before you begin.

1. Know the browsers

As an end user requests a page on your site, Script Management installs a JavaScript service worker called akam-sw.js. It's used to apply a policy that you'll create to manage scripts. It can only be installed with a supported browser:

  • Chrome (desktop and mobile)
  • Firefox (desktop and mobile)
  • Safari (desktop only)

📘

To test your Script Management setup, you'll need to have local access to the Chrome browser.

2. Create your Ion property

You'll use PAPI to create a new Ion property. Review the sections that follow to get going with the process.

Ion's productIds

You'll need to get the productId value for the version of Ion you're using. PAPI uses the codename values that ​Akamai​ established for the various versions during its development:

  • Ion Premier. "SPM"
  • Ion Standard. "FRESCA"

For example, if you run the list products operation in PAPI, the response data for each version of Ion would look like this:

{
    "accountId": "abc_A-1-BCDEF",
    "contractId": "ctr_1-GHIJK",
    "products": {
        "items": [
            {
                "productName": "SPM",
                "productId": "prd_SPM"
            }
        ]
    }
}
{
    "accountId": "abc_A-1-BCDEF",
    "contractId": "ctr_1-GHIJK",
    "products": {
        "items": [
            {
                "productName": "Fresca",
                "productId": "prd_FRESCA"
            }
        ]
    }
}

Set it up for HTTPS

HTTPS is the standard for protecting traffic on the web. You'll apply it to protect the connection between a client requesting your content and the ​Akamai​ edge network. Follow this tutorial to create a property using a custom certificate to secure the connection:

  1. Complete phases 1 - 9 in the tutorial.

  2. Store these values:

    • propertyVersion. This should be 1 because you're creating a new Ion property with this tutorial.
    • propertyId. The unique identifier that ​Akamai​ assigns to your new property.
  3. Return here and continue to the next phase.

3. Get and store your rule tree

Access your Ion property's rule tree and store it. Use the propertyVersion and propertyId values you stored for your Ion property.

Get a property tree
Open Recipe

4. Edit your rule tree

Here, you'll enable Script Management in your property, and verify that two other required behaviors are enabled. Use the response output you stored from the get the rule tree operation to serve as the body parameters for the operation:

Patch a rule tree
Open Recipe

👍

We offer plugins to help with a rule tree

Rule trees are maintained in a special form of JSON. We offer two tools you can use to help navigate and edit your rule tree. Check out the VS code or Eclipse IDE plugins.

http3

This behavior just needs to remain in the rule tree, set to "enable": "true". Set this way, the default value of enabled is used.

{
    "name": "http3",
    "options": {
        "enable": true
    }
},

📘

HTTP/2 is still supported

This older protocol is still supported and automatically included in your rule tree. Leave it in to ensure full support.

mpulse RUM

You need real-user monitoring (RUM) support to use Script Management. By default, mPulse is enabled for RUM support in a new Ion property. There are several other options you can apply for this behavior. At a minimum, you need to ensure that "enabled": true is set:

{
  "name": "mPulse RUM",
  "children": [],
  "behaviors": [
    {
      "name": "mPulse",
      "options": {
        "apiKey": "",
        "bufferSize": "",
        "configOverride": "",
        "enabled": true,
        "loaderVersion": "V12",
        "requirePci": false,
        "titleOptional": ""
      }
    }
  ],
  "criteria": [],
  "criteriaMustSatisfy": "all",
  "comments": "Collect..."
},

scriptManagement

Update this behavior's settings to enable it.

  • enabled. Set to true to enable it.
  • serviceworker. Set to YES_SERVICE_WORKER to set Script Management to "Analysis and Action" mode. You'll be able to review script usage and create a policy to manage selected scripts.

{
  "name": "Script management",
  "children": [],
  "behaviors": [
    {
      "name": "scriptManagement",
      "options": {
        "enabled": true,
        "serviceworker": "YES_SERVICE_WORKER"
      }
    }
  ],
  "criteria": [],
  "criteriaMustSatisfy": "all",
  "comments": "Enable..."
}

5. Finish your property

With Script Management set up the way you want, you're ready to finish onboarding your property and start delivering your content. Return to this tutorial and complete steps 12 - 17.