|
@@ 308-313 (lines=6) @@
|
| 305 |
|
|
| 306 |
|
private function script_has_deps( $handle ) { |
| 307 |
|
global $wp_scripts; |
| 308 |
|
foreach ( $wp_scripts->to_do as $other_script_handle ) { |
| 309 |
|
$other_script = $wp_scripts->registered[ $other_script_handle ]; |
| 310 |
|
if ( in_array( $handle, $other_script->deps ) ) { |
| 311 |
|
return true; |
| 312 |
|
} |
| 313 |
|
} |
| 314 |
|
|
| 315 |
|
return false; |
| 316 |
|
} |
|
@@ 325-331 (lines=7) @@
|
| 322 |
|
$should_defer_script = $script->args === 0; |
| 323 |
|
|
| 324 |
|
// only make scripts deferred if nothing depends on them |
| 325 |
|
foreach ( $wp_scripts->to_do as $other_script_handle ) { |
| 326 |
|
$other_script = $wp_scripts->registered[ $other_script_handle ]; |
| 327 |
|
if ( in_array( $script->handle, $other_script->deps ) ) { |
| 328 |
|
$should_defer_script = false; |
| 329 |
|
break; |
| 330 |
|
} |
| 331 |
|
} |
| 332 |
|
|
| 333 |
|
$should_defer_script = $should_defer_script || ( isset( $script->extra['jetpack-defer'] ) && $script->extra['jetpack-defer'] ); |
| 334 |
|
return $this->defer_scripts && apply_filters( 'jetpack_perf_defer_script', $should_defer_script, $script->handle, $script->src ); |