Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 1
CRAP
n/a
0 / 0
Automattic\Jetpack_Boost\Compatibility\Jetpack\exclude_jetpack_likes_scripts_defer
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2/**
3 * Jetpack compatibility for Boost
4 *
5 * @package automattic/jetpack-boost
6 */
7
8namespace Automattic\Jetpack_Boost\Compatibility\Jetpack;
9
10require_once __DIR__ . '/lib/class-sync-jetpack-module-status.php';
11
12( new Sync_Jetpack_Module_Status( 'image_cdn', 'photon' ) )->init();
13
14/**
15 * Exclude Jetpack likes scripts from deferred JS. They are already in the footer,
16 * and are sensitive to having their order changed relative to their companion iframe.
17 *
18 * The queue handler is listed unconditionally: the Like block and Comment Likes enqueue it
19 * without the `likes` module, so is_module_active( 'likes' ) would miss them.
20 *
21 * @param array $exclusions The default array of scripts to exclude from deferral.
22 */
23function exclude_jetpack_likes_scripts_defer( $exclusions ) {
24    static $likes_enabled = null;
25
26    $exclusions[] = 'jetpack_likes_queuehandler';
27
28    if ( null === $likes_enabled ) {
29        $likes_enabled = \Jetpack::is_module_active( 'likes' );
30    }
31
32    if ( $likes_enabled ) {
33        return array_merge(
34            $exclusions,
35            array(
36                'jquery-core',
37                'postmessage',
38            )
39        );
40    }
41
42    return $exclusions;
43}
44
45add_filter( 'jetpack_boost_render_blocking_js_exclude_handles', __NAMESPACE__ . '\exclude_jetpack_likes_scripts_defer', 10, 1 );