/home/vianto5/heredit.mx/wp-content/plugins/wp-rocket/inc/Engine/Optimization/Minify/JS
Edit: /home/vianto5/heredit.mx/wp-content/plugins/wp-rocket/inc/Engine/Optimization/Minify/JS/Minify.php (8007B)
get_scripts( $html );
if ( empty( $scripts ) ) {
return $html;
}
foreach ( $scripts as $script ) {
global $wp_scripts;
$is_external_url = $this->is_external_file( $script['url'] );
if (
! $is_external_url
&&
preg_match( '/[-.]min\.js/iU', $script['url'] )
) {
Logger::debug(
'Script is already minified.',
[
'js minification process',
'tag' => $script[0],
]
);
continue;
}
if (
$is_external_url
&&
$this->is_excluded_external( $script['url'] )
) {
continue;
}
if ( $this->is_minify_excluded_file( $script ) ) {
Logger::debug(
'Script is excluded.',
[
'js minification process',
'tag' => $script[0],
]
);
continue;
}
// Don't minify jQuery included in WP core since it's already minified but without .min in the filename.
if ( ! empty( $wp_scripts->registered['jquery-core']->src ) && false !== strpos( $script['url'], $wp_scripts->registered['jquery-core']->src ) ) {
Logger::debug(
'jQuery script is already minified.',
[
'js minification process',
'tag' => $script[0],
]
);
continue;
}
$integrity_validated = $this->local_cache->validate_integrity( $script );
if ( false === $integrity_validated ) {
Logger::debug(
'Script integrity attribute not valid.',
[
'js minification process',
'tag' => $script[0],
]
);
continue;
}
$script['final'] = $integrity_validated;
$minify_url = $this->replace_url( strtok( $script['url'], '?' ) );
if ( ! $minify_url ) {
Logger::error(
'Script minification failed.',
[
'js minification process',
'tag' => $script[0],
]
);
continue;
}
$html = $this->replace_script( $script, $minify_url, $html );
}
return $html;
}
/**
* Get all script tags from HTML.
*
* @param string $html HTML content.
* @return array Array with script tags, empty array if no script tags found.
*/
private function get_scripts( $html ) {
$html_nocomments = $this->hide_comments( $html );
$scripts = $this->find( '