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 * @param array $exclusions The default array of scripts to exclude from deferral.
19 */
20function exclude_jetpack_likes_scripts_defer( $exclusions ) {
21    static $likes_enabled = null;
22
23    if ( null === $likes_enabled ) {
24        $likes_enabled = \Jetpack::is_module_active( 'likes' );
25    }
26
27    if ( $likes_enabled ) {
28        return array_merge(
29            $exclusions,
30            array(
31                'jquery-core',
32                'postmessage',
33                'jetpack_likes_queuehandler',
34            )
35        );
36    }
37
38    return $exclusions;
39}
40
41add_filter( 'jetpack_boost_render_blocking_js_exclude_handles', __NAMESPACE__ . '\exclude_jetpack_likes_scripts_defer', 10, 1 );