Script Management

Script Management is a suite of tools to help you minimize performance degradation from third-party JavaScripts.

How it works

This behavior shows you which scripts referenced on your site are causing the largest impacts to performance. You can use this information to modify how your site uses JavaScripts. Also, you can create Script Management policies that automatically block or defer scripts and ensure that single points of failure do not stop pages from loading. Testing suggestions help you find the most popular pages that your policy affects, so you can confirm that Script Management is working as intended.

Implementation

  1. If you haven't yet done so, set up mPulse. See the quick start instructions in the mPulse documentation.

  2. In Property Manager, edit a new version of your property configuration.

  3. Add the Script Management behavior and enable it.

🚧

In your property configuration, the Script Management rule must apply only at the root scope. Don't use match criteria that enable Script Management at any other scope. You can, however, add a hostname match condition to restrict Script Management to specific hosts in your property.

🚧

Make sure that any rules after the Script Management rule do not apply the Origin Server behavior. (Cloudlets Origins, configured with the Cloudlets Origin Group rule, can however, appear after the Script Management rule.)

  1. Select one of the following modes in which you want to run Script Management.
  • Analysis only.

  • Analysis and action.

  1. Save and activate this configuration version in staging. Confirm it's working correctly, and activate on production.

Script Management begins collecting real-time data about resources used on your property. If you've just set up mPulse on your property, allow some time for data collection before continuing.

About service workers

Script Management uses a type of script called a service worker to block and defer scripts. The Script Management service worker can coexist with other service workers on the site. When the Script Management service worker is registered, it acts as a proxy for any other service workers and forwards events to them after it is done handling them.

A service worker is a code that runs in the background and performs tasks separate from the page and user interactions. They can monitor and intercept network activity, handle push notifications, and initiate background fetches. A common use for a service worker is to ensure applications continue to work even when the user loses connectivity: The service worker caches resources in the browser and can serve them if the browser goes offline.

Script Management is an example of another common use of service workers: managing requests. It monitors requests from the page and compares them to the Script Management policy. If it sees a request for a script that it should block, it stops the request before it is sent. If it sees a request for a script that it should defer, it moves it to the background, loading it in a way that doesn't block the page's content from rendering.

Check the Script Management service worker

πŸ“˜

The Script Management service worker only installs in supported browsers. At this time, the supported browsers are the latest versions of the following:

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

When you test your Script Management policies, use the developer tools on your site's pages to find out which service workers have loaded. This example demonstrates how to find the source name in Chrome's developer tools.

  1. Accessing developer tools

  1. Checking service workers

Interpreting service worker status

Developer tools indicatorsService worker statusNext steps
The value in the source field is
akam-sw.js
There is no problem with the Script Management service worker.Proceed with your testing.
The value
akam-sw.js
does not appear in the source field.
Script Management is not enabled or you are using an unsupported browser.Check that Script Management is enabled in a property configuration that is active on production.
The developer tools have no option to view service workers.This browser does not support service workers.Use a supported browser, such as Chrome.

πŸ“˜

Refreshing the browser doesn't always refresh the service workers. Try closing the browser entirely and relaunching.

Related topics

See also these topics in the Script Management documentation:


Did this page help you?