Skip to content

Commit

Permalink
Merge pull request #2563 from WPO-Foundation/2544
Browse files Browse the repository at this point in the history
Don't recommend priority hints if they're already there
  • Loading branch information
scottjehl authored Dec 1, 2022
2 parents 33bdc74 + 00c21f9 commit 081950c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 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,10 @@ 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')) {
$suggest_priority_hints = !$isBG && !$isVideo && !$hasHighFetchPriority;
if ($suggest_priority_hints) {
$expsToAdd[] = (object) [
"id" => '011',
'title' => 'Add Priority Hint',
Expand Down

0 comments on commit 081950c

Please sign in to comment.