Hooks
modal_kit_optimizer_paths
filter
Free
PHP
Folders that speed and cache plugins must not combine, delay or move to a CDN. Add yours if your add-on has its own script modules. Pro adds its folder.
Modal Kit’s runtime is a script module that imports core’s @wordpress/interactivity, and its styles must load whole before a modal opens. Several speed and cache plugins break that, so Modal Kit keeps its folder out of their way, with nothing to set. This filter is that list of folders; Modal Kit Pro adds its own.
The list goes to SiteGround Speed Optimizer (not combined with other JavaScript), Breeze and W3 Total Cache (kept off their CDN, together with core’s /core/js/dist/script-modules/), LiteSpeed Cache (left out of its combined, unique and critical CSS) and, on pages with modals, 10Web Booster and NitroPack (their opt-out attribute on script modules from these folders). Each of these does nothing when its plugin isn’t active.
Parameters
Parameter
Description
$paths
array<int, string>
URL paths from the site root, each ending in a slash. Default: Modal Kit’s folder, such as /content/modules/modal-kit/.
Returns
array<int, string> The paths. Values are cast to strings, empty ones are dropped and the list is re-indexed.
Example
Add your add-on’s folder
In your plugin’s main file. This is what Modal Kit Pro does.
add_filter( 'modal_kit_optimizer_paths', function ( $paths ) {
$paths = is_array( $paths ) ? $paths : array();
$paths[] = (string) wp_parse_url(
plugin_dir_url( __FILE__ ),
PHP_URL_PATH
);
return $paths;
} );
Good to know
Add to the list; don’t replace it. Without Modal Kit’s folder, the optimisers can break its runtime again.
The list isn’t stored: it’s read during the page build, each time one of those plugins asks.
Some handling goes by style handle, not by folder: Jetpack Boost, 10Web Booster’s stylesheet opt-out and LiteSpeed’s “remove query strings” leave alone the stylesheets whose handles start with modal-kit-.
Applied in modal-kit/includes/Integrations/Optimizers.php.