# Speed optimizations

> Remove jQuery Migrate, preload the files in the head, and defer scripts, so pages start drawing sooner.

Source: https://docs.wpwaterfall.com/speed-optimizations

Speed optimizations are three front end changes that make a page start drawing sooner. Each one is a switch for one environment, on the **Tools** tab.

## What does each part do?

- **Remove jQuery Migrate**: visitors load jQuery without jQuery Migrate, a script that only old plugins need. wp-admin, the login page, and the Customizer keep it. A page where a script asks for `jquery-migrate` by name keeps it too.
- **Preload hints and Early Hints**: every page sends `Link: rel=preload` headers for your site's own stylesheets and scripts in the head, at most 6. Cloudflare answers them as 103 Early Hints, so the browser fetches them while the page is still on its way. People who are signed in get no headers. This is the only Early Hints switch: there is no separate Early Hints card. An environment that had the old Early Hints card on has this part on.
- **Defer scripts**: scripts in the head and the footer, jQuery included, load with `defer`, so they no longer hold up the first paint. A script with inline code, or one that inline code depends on, stays as it is. This part can break a plugin or theme that prints its own inline script calling jQuery, so test your site after you turn it on.

## Which sites have them on?

A site you create gets **Remove jQuery Migrate** and **Preload hints and Early Hints** on, and **Defer scripts** off. Its staging, live, and preview environments start with the settings of the environment they come from.

A site from before speed optimizations, and a site you [migrate](https://docs.wpwaterfall.com/migrate-a-site), start with all three off, because their plugins were never tested with them. Turn each part on when you are ready.

## How do I change them?

1. Open your site, pick the environment, and go to **Tools**.
2. On **Speed optimizations**, choose **Modify** (or **Enable** while all three are off).
3. Check or clear each part, then choose **Save**.

The change is a job. It applies the settings on the server and clears your site's caches, because cached pages hold the old script tags. You need the permission to manage edge settings. With the API, send `PUT /v1/environments/{id}/tools/speed`. With an assistant, use the `set_speed_optimizations` tool.

## Does it change my files or database?

No. The WP Waterfall must-use plugin makes the changes while WordPress builds each page. Turn a part off and the next page is as WordPress prints it.

## What else does WP Waterfall do for speed?

- Static files that WordPress asks for with `?ver=` get `Cache-Control: public, max-age=31536000, immutable` on a read-only release, so a returning visitor's browser does not ask for them again. Other static files keep 7 days. In SFTP mode they are not cached, so an edit shows at once. A theme or plugin that changes its code without a new version keeps the old file for returning visitors until its version changes.
- Cloudflare inlines Google Fonts stylesheets, so there is nothing to change for fonts.

## What if a plugin stops working?

Turn off the part you turned on last, then check the page again in a private window. **Defer scripts** is the part most likely to cause it. A server whose agent is older than speed optimizations ignores them, and the job says the server needs an agent update.
