Create a policy

Once you've reviewed script usage, create a policy to manage potentially problematic scripts on your site or app.

The Script Management API


Review these sections to create a policy using the API.

1. Create a policy

With problematic scripts identified, create a Script Management policy to apply to requests for a specific property hostname (domain) in your Ion property. To start, set one up so you can test it.

2. Test your policy

With your policy activated, perform these steps to test it:

  1. Launch the Chrome browser.

  2. Download the Script Management Policy Tester from the Chrome web store.

  3. Navigate to one of the pages you noted for a script you included in your policy.

  4. Open the developer tools console:

    • macOS. Press Command+Opt+I.
    • Windows. Press Ctrl+Shift+I.
  5. Select the SM tab from the console. (You may need to click >> to reveal this tab.)

  1. Click Retrieve policies.

  2. Select the policy you created and click Load policy.

  3. Click Apply version locally. The akam-sw.js service worker is loaded and the page is refreshed.

📘

This testing process only applies the akam-sw.js and the staging version of your Script Management policy in your local browser. It won't impact the production version of your Script Management property or your public-facing site.

  1. Test the functionality on the page to make sure that it performs properly. Specifically, make sure that the script you blocked or deferred isn't negatively affecting the page.

  2. Navigate to the other pages you noted that use scripts included in your policy and make sure they work properly.

Make changes to your policy

If you discover inconsistencies during testing, you can update your policy. First, get and store details for your policy:

Now, use the same operation you used to create your policy, to update it.

📘

You don't need the "versionId" and "activationTime" from the stored policy content.

Finally, repeat the testing process to verify your updates.

3. Go live with your policy

Once you've finished testing and you're ready to go live with your policy, you need to push it to the production network to actively manage scripts for end-user requests.

The Script Management dashboard


Review these sections to create a policy using ​Akamai Control Center​.

1. Create a new policy

Use the Script Management dashboard to create a Script Management policy to apply to requests for a specific property hostname (domain) in your Ion property.

  1. In ​Control Center​, go to > CDN > Script Management.

  2. Set the following:

    • Group. Select the Group ID you used to create your Ion property.
    • Property. Select your Ion property name.
    • Hostname. Select the appropriate Property Hostname.
  3. Click Go to editing.

  4. Select the Analysis header in the table to sort High impact scripts to the top of the table. You can click an entry to review more details in the Information column.

  5. Select Actions (...) for the entry and pick how you want to handle this script:

    • Defer. This will postpone the script from loading until its associated page is reloaded. This prevents the script from rerunning.
    • Block. This completely prevents the script from loading.
  6. Make note of the following for use in testing:

    • The name of the script.
    • A page on your site where it's used.
  7. Repeat steps 3-4 for the remaining High entries in the table.

👍

Consider repeating this process for the Medium entries listed in the table, too. You should at least review them to see how they might be impacting your site.

  1. You can optionally add Single Point of Failure Protection or an Override List to your policy.

  2. Click Staging Analysis only.

  3. Review your policy and click OK once you're satisfied.

  4. Wait for activation to complete. This can take up to 15 minutes, but it typically finishes sooner. You'll get a Notification message in ​Control Center​ when the policy is complete.

2. Test your policy

With your policy activated, perform these steps to test it:

📘

This testing process only applies the akam-sw.js and the staging version of your Script Management policy in your local browser. It won't impact the production version of your Script Management property or your public-facing site.

  1. Launch the Chrome browser.

  2. Download the Script Management Policy Tester from the Chrome web store.

  3. Navigate to one of the pages you noted for a script you included in your policy.

  4. Open the developer tools console:

    • macOS. Press Command+Opt+I.
    • Windows. Press Ctrl+Shift+I.
  5. Select the SM tab from the console. (You may need to click >> to reveal this tab.)

  1. Click Retrieve policies.

  2. Select the policy you created and click Load policy. The Policy Tester displays information about the selected policy, very similar to what you see in the Script Management dashboard on ​Control Center​ :

    • Summary information
    • Each script's action
    • Transfer size
    • Transfer time
    • Analysis
  3. Click Apply version locally. The akam-sw.js service worker is loaded and the page is refreshed.

  4. Test the functionality on the page to make sure that it performs properly. Specifically, make sure that the script you blocked or deferred isn't negatively affecting the page.

  5. Navigate to the other pages you noted that use scripts included in your policy and make sure they work properly.

If you run into any problems that you're sure are script-related, you can edit your policy in the Script Management Dashboard and retest. Otherwise, you're ready to go live with it.

3. Go live with your policy

Once you're happy with your policy after testing, go live with it to apply its settings to your public-facing site.

  1. If necessary, access Control Center.

  2. Go to > CDN > Script Management.

  3. Select the Group, the Property, and the Hostname you used to create your policy.

  4. Set View Policy Active to Staging.

  5. Click Go to editing.

  6. Review your policy's settings. Make sure it's set up the way you want.

  7. Click Production.

Now, you just need to wait for the activation to complete. You'll get another Notification message in ​Control Center​ when the policy is complete. At that point, your policy will be deferring or blocking scripts on the customer-facing site you're delivering through your Script Management property.