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:
-
Launch the Chrome browser.
-
Download the Script Management Policy Tester from the Chrome web store.
-
Navigate to one of the pages you noted for a script you included in your policy.
-
Open the developer tools console:
- macOS. Press Command+Opt+I.
- Windows. Press Ctrl+Shift+I.
-
Select the SM tab from the console. (You may need to click >> to reveal this tab.)
-
Click Retrieve policies.
-
Select the policy you created and click Load policy.
-
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.
-
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.
-
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.
-
In Control Center, go to ☰ > CDN > Script Management.
-
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.
-
Click Go to editing.
-
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.
-
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.
-
Make note of the following for use in testing:
- The name of the script.
- A page on your site where it's used.
-
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.
-
You can optionally add Single Point of Failure Protection or an Override List to your policy.
-
Click Staging Analysis only.
-
Review your policy and click OK once you're satisfied.
-
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.
-
Launch the Chrome browser.
-
Download the Script Management Policy Tester from the Chrome web store.
-
Navigate to one of the pages you noted for a script you included in your policy.
-
Open the developer tools console:
- macOS. Press Command+Opt+I.
- Windows. Press Ctrl+Shift+I.
-
Select the SM tab from the console. (You may need to click >> to reveal this tab.)
-
Click Retrieve policies.
-
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
-
Click Apply version locally. The
akam-sw.js
service worker is loaded and the page is refreshed. -
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.
-
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.
-
If necessary, access Control Center.
-
Go to ☰ > CDN > Script Management.
-
Select the Group, the Property, and the Hostname you used to create your policy.
-
Set View Policy Active to Staging.
-
Click Go to editing.
-
Review your policy's settings. Make sure it's set up the way you want.
-
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.
Updated almost 2 years ago