Felder wie in Measurement 'html' (ohne asset_headers). */ public static function analyze( $html, $home_url = '' ) { $empty = array( 'is_html' => false, 'bytes' => 0, 'emoji_tags' => 0, 'version_urls' => 0, 'asset_count' => 0, 'blocking_scripts' => 0, 'blocking_handles' => array(), 'external_hosts' => array(), 'hinted_hosts' => array(), 'sample_assets' => array(), ); if ( ! is_string( $html ) || '' === $html ) { return $empty; } $result = $empty; $result['bytes'] = strlen( $html ); // Ohne -Tag ist unklar, was das ist (Fehlerseite, Feed, Teilausgabe). if ( ! preg_match( '/]/i', $html ) ) { return $result; } $result['is_html'] = true; $home_host = self::host( $home_url ); $home_base = self::origin( $home_url ); $head = ''; if ( preg_match( '/
]*>(.*?)<\/head>/is', $html, $m ) ) { $head = $m[1]; } $with_inline = array(); $assets = array(); $hosts = array(); $samples = array(); // Stylesheets. preg_match_all( '/]*>/i', $html, $links ); foreach ( $links[0] as $tag ) { $rel = strtolower( (string) self::attr( $tag, 'rel' ) ); $href = (string) self::attr( $tag, 'href' ); if ( '' === $href ) { continue; } if ( false !== strpos( $rel, 'stylesheet' ) ) { $assets[ $href ] = true; self::collect( $href, 'css', $home_host, $home_base, $hosts, $samples ); } elseif ( false !== strpos( $rel, 'preconnect' ) || false !== strpos( $rel, 'dns-prefetch' ) ) { $hint_host = self::host( 0 === strpos( $href, '//' ) ? 'https:' . $href : $href ); if ( '' !== $hint_host && ! in_array( $hint_host, $result['hinted_hosts'], true ) && count( $result['hinted_hosts'] ) < 30 ) { $result['hinted_hosts'][] = $hint_host; } } elseif ( false !== strpos( $rel, 'preload' ) || false !== strpos( $rel, 'icon' ) ) { self::collect( $href, '', $home_host, $home_base, $hosts, $samples ); } } // Skripte. preg_match_all( '/