Code Duplication    Length = 6-7 lines in 2 locations

modules/perf/class.jetpack-perf-optimize-assets.php 2 locations

@@ 384-389 (lines=6) @@
381
382
	private function script_has_deps( $handle ) {
383
		global $wp_scripts;
384
                foreach ( $wp_scripts->to_do as $other_script_handle ) {
385
                        $other_script = $wp_scripts->registered[ $other_script_handle ];
386
                        if ( in_array( $handle, $other_script->deps ) ) {
387
				return true;
388
                        }
389
                }
390
391
		return false;
392
	}
@@ 401-407 (lines=7) @@
398
		$should_defer_script = $script->args === 0;
399
400
		// only make scripts deferred if nothing depends on them
401
		foreach ( $wp_scripts->to_do as $other_script_handle ) {
402
			$other_script = $wp_scripts->registered[ $other_script_handle ];
403
			if ( in_array( $script->handle, $other_script->deps ) ) {
404
				$should_defer_script = false;
405
				break;
406
			}
407
		}
408
409
		$should_defer_script = $should_defer_script || ( isset( $script->extra['jetpack-defer'] ) && $script->extra['jetpack-defer'] );
410
		return $this->defer_scripts && apply_filters( 'jetpack_perf_defer_script', $should_defer_script, $script->handle, $script->src );