Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't recommend priority hints if they're already there #2563

Merged
merged 2 commits into from
Dec 1, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions www/experiments/lcp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ if (isset($lcp)) {
if ($lcp['time'] > 2500) {
$isBG = false;
$isVideo = false;

$hasHighFetchPriority = false;
if (isset($lcp['element']['outerHTML'])) {
$lcpHTML = '<code class="language-html">' . htmlentities($lcp['element']['outerHTML']) . '</code>';
$hasHighFetchPriority = preg_match('/fetchpriority\="?high"?/i', $lcp['element']['outerHTML']) === 1;
}

if (isset($lcp['type']) && $lcp['type'] === "image") {
Expand Down Expand Up @@ -74,8 +75,9 @@ if (isset($lcp)) {
"expval" => array($lcpSource . "|as_image"),
"explabel" => array($lcpSource)
];

// priority Hints only help for foreground images
if (!$isBG && !$isVideo && !(isset($lcp['element']['fetchPriority']) && $lcp['element']['fetchPriority'] == 'high')) {
if (!$isBG && !$isVideo && !$hasHighFetchPriority) {
scottjehl marked this conversation as resolved.
Show resolved Hide resolved
$expsToAdd[] = (object) [
"id" => '011',
'title' => 'Add Priority Hint',
Expand Down