Skip to content

[00] Subset Opt-Out, User guide

Autoptimize

Last updated

How Subset Opt-Out keeps its scripts out of Autoptimize's JavaScript optimisation, when to clear Autoptimize's cache, and the limits.

Subset Opt-Out works with Autoptimize’s JavaScript optimisation, with no exclusions for you to add. It keeps its own scripts out of Autoptimize’s minified and aggregated files, so they still run first and in order.

What works

Subset Opt-Out relies on two inline scripts in <head> and one script file. They have to run unchanged, in order, before any tracker. With Optimize JavaScript Code? and Aggregate JS-files? on, Autoptimize would otherwise minify them, move them and combine them with other scripts. Subset Opt-Out:

  • adds its script file, its inline scripts and their ids to the list behind Exclude scripts from Autoptimize:, after the entries already there
  • marks its script file as already minified, so Autoptimize serves it from its own URL instead of copying it to Autoptimize’s cache
  • adds data-cfasync="false" to its script tags, an attribute Autoptimize’s code also leaves out of aggregation

The setting names come from Autoptimize’s settings screen, in its source code (opens in a new tab). The attributes it skips are in its script handling (opens in a new tab).

Held trackers are printed as type="text/plain", which the browser doesn’t run. Subset Opt-Out turns them back into scripts, in order, once the visitor’s choice allows them.

What needs a setting

Nothing in Autoptimize. Clear its cache after you install Subset Opt-Out, and again after you switch a service on or off or add a custom rule. If a page cache sits in front of Autoptimize, clear that too.

Then test a page as an opted-out visitor, or with Global Privacy Control turned on in your browser. Global Privacy Control shows how to check what’s held.

Known limits

  • A tracker no service matches isn’t held. Autoptimize optimises it like any other script, and it runs for everyone. Add a custom rule under Subset → Opt-Out for it.
  • Scripts above wp_head run first. A tracker printed before wp_head(), or moved above it, runs before Subset Opt-Out can hold it.
  • Your own exclusions stay. Subset Opt-Out adds to the exclusion list and never removes what you’ve entered.