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

closes #6672 add attribute to link preload #6674

Merged
merged 9 commits into from
Jun 19, 2024
Merged
2 changes: 1 addition & 1 deletion inc/Engine/Media/AboveTheFold/Frontend/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ private function generate_lcp_link_tag_with_sources( $lcp ): array {
}

$tag = '';
$start_tag = '<link rel="preload" as="image" ';
$start_tag = '<link rel="preload" data-rocket-preload as="image" ';
$end_tag = ' fetchpriority="high">';

$sources = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected function get_font_display_value(): string {
*/
protected function get_optimized_markup( string $url ): string {
return sprintf(
'<link rel="preload" as="style" href="%1$s" /><link rel="stylesheet" href="%1$s" media="print" onload="this.media=\'all\'" /><noscript><link rel="stylesheet" href="%1$s" /></noscript>', // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet
'<link rel="preload" data-rocket-preload as="style" href="%1$s" /><link rel="stylesheet" href="%1$s" media="print" onload="this.media=\'all\'" /><noscript><link rel="stylesheet" href="%1$s" /></noscript>', // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet
$url
);
}
Expand Down
2 changes: 1 addition & 1 deletion inc/Engine/Optimization/RUCSS/Controller/UsedCSS.php
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ private function preload_links( array $urls ): string {
$links = '';

foreach ( $urls as $url ) {
$links .= '<link rel="preload" as="font" href="' . esc_url( $url ) . '" crossorigin>';
$links .= '<link rel="preload" data-rocket-preload as="font" href="' . esc_url( $url ) . '" crossorigin>';
}

return $links;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<html>
<head>
<?php wp_head() ?>
<title>lcp_bg_responsive_template</title><link rel="preload" as="image" imagesrcset="http://example.org/wp-content/rocket-test-data/images/lcp/testavif.avif 1dppx,http://example.org/wp-content/rocket-test-data/images/lcp/testwebp.webp 2dppx" fetchpriority="high">
<title>lcp_bg_responsive_template</title><link rel="preload" data-rocket-preload as="image" imagesrcset="http://example.org/wp-content/rocket-test-data/images/lcp/testavif.avif 1dppx,http://example.org/wp-content/rocket-test-data/images/lcp/testwebp.webp 2dppx" fetchpriority="high">
<style>
.imgset-css-background-images{
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<html>
<head>
<?php wp_head() ?>
<title>lcp_bg_responsive_template</title><link rel="preload" as="image" imagesrcset="https://fastly.picsum.photos/id/976/200/300.jpg?hmac=s1Uz9fgJv32r8elfaIYn7pLpQXps7X9oYNwC5XirhO8 1dppx,https://rocketlabsqa.ovh/wp-content/rocket-test-data/images/fixtheissue.jpg 2dppx" fetchpriority="high">
<title>lcp_bg_responsive_template</title><link rel="preload" data-rocket-preload as="image" imagesrcset="https://fastly.picsum.photos/id/976/200/300.jpg?hmac=s1Uz9fgJv32r8elfaIYn7pLpQXps7X9oYNwC5XirhO8 1dppx,https://rocketlabsqa.ovh/wp-content/rocket-test-data/images/fixtheissue.jpg 2dppx" fetchpriority="high">
<style>
.webkit-BG-images-external-domain {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<head>
<title>LCP/ATF image test</title><link rel="preload" as="image" href="http://example.org/wp-content/uploads/sample_url_image.png" fetchpriority="high">
<title>LCP/ATF image test</title><link rel="preload" data-rocket-preload as="image" href="http://example.org/wp-content/uploads/sample_url_image.png" fetchpriority="high">
</head>
<body>
<img fetchpriority="high" src="//example.org/wp-content/uploads/sample_url_image.png" alt="Sample alt">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<html>
<head>
<?php wp_head() ?>
<title>lcp_layered_bg</title><link rel="preload" as="image" href="https://fastly.picsum.photos/id/976/200/300.jpg?hmac=s1Uz9fgJv32r8elfaIYn7pLpQXps7X9oYNwC5XirhO8" fetchpriority="high"><link rel="preload" as="image" href="https://rocketlabsqa.ovh/wp-content/rocket-test-data/images/fixtheissue.jpg" fetchpriority="high">
<title>lcp_layered_bg</title><link rel="preload" data-rocket-preload as="image" href="https://fastly.picsum.photos/id/976/200/300.jpg?hmac=s1Uz9fgJv32r8elfaIYn7pLpQXps7X9oYNwC5XirhO8" fetchpriority="high"><link rel="preload" data-rocket-preload as="image" href="https://rocketlabsqa.ovh/wp-content/rocket-test-data/images/fixtheissue.jpg" fetchpriority="high">
<style>
.bg-layared-css-background-images{
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<html>
<head>
<?php wp_head() ?>
<title>lcp_responsive_bg</title><link rel="preload" as="image" href="small_cat.jpg" media="(max-width: 400px)" fetchpriority="high"><link rel="preload" as="image" href="medium_cat.jpg" media="(min-width: 400.1px) and (max-width: 800px)" fetchpriority="high"><link rel="preload" as="image" href="large_cat.jpg" media="(min-width: 800.1px)" fetchpriority="high">
<title>lcp_responsive_bg</title><link rel="preload" data-rocket-preload as="image" href="small_cat.jpg" media="(max-width: 400px)" fetchpriority="high"><link rel="preload" data-rocket-preload as="image" href="medium_cat.jpg" media="(min-width: 400.1px) and (max-width: 800px)" fetchpriority="high"><link rel="preload" data-rocket-preload as="image" href="large_cat.jpg" media="(min-width: 800.1px)" fetchpriority="high">
</head>
<body>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<html>
<head>
<?php wp_head() ?>
<title>lcp_responsive_bg</title><link rel="preload" as="image" imagesrcset="https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-1024x576.jpg.avif 1024w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-300x169.jpg.avif 300w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-768x432.jpg.avif 768w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-1536x864.jpg.avif 1536w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-1200x675.jpg.avif 1200w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-600x338.jpg.avif 600w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia.jpg.avif 1920w" imagesizes="(max-width: 1024px) 100vw, 1024px" fetchpriority="high">
<title>lcp_responsive_bg</title><link rel="preload" data-rocket-preload as="image" imagesrcset="https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-1024x576.jpg.avif 1024w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-300x169.jpg.avif 300w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-768x432.jpg.avif 768w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-1536x864.jpg.avif 1536w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-1200x675.jpg.avif 1200w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-600x338.jpg.avif 600w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia.jpg.avif 1920w" imagesizes="(max-width: 1024px) 100vw, 1024px" fetchpriority="high">
</head>
<body>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<html>
<head>
<?php wp_head() ?>
<title>lcp_responsive_bg</title><link rel="preload" as="image" imagesrcset="https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-1024x576.jpg.avif 1024w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-300x169.jpg.avif 300w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-768x432.jpg.avif 768w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-1536x864.jpg.avif 1536w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-1200x675.jpg.avif 1200w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-600x338.jpg.avif 600w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia.jpg.avif 1920w" imagesizes="(max-width: 1024px) 100vw, 1024px" fetchpriority="high">
<title>lcp_responsive_bg</title><link rel="preload" data-rocket-preload as="image" imagesrcset="https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-1024x576.jpg.avif 1024w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-300x169.jpg.avif 300w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-768x432.jpg.avif 768w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-1536x864.jpg.avif 1536w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-1200x675.jpg.avif 1200w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia-600x338.jpg.avif 600w, https://imagify.rocketlabsqa.ovh/wp-content/uploads/2024/05/home-new-bg-free-img-—-kopia.jpg.avif 1920w" imagesizes="(max-width: 1024px) 100vw, 1024px" fetchpriority="high">
</head>
<body>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<html>
<head>
<?php wp_head() ?>
<title>lcp_responsive_bg</title><link rel="preload" as="image" href="https://variance.pl/wp-content/uploads/2024/05/Kwiatowy-Ksiezyc-400x600.webp" media="(max-width: 500px)" fetchpriority="high"><link rel="preload" as="image" href="https://variance.pl/wp-content/uploads/2024/05/Kwiatowy-Ksiezyc-768x513.webp" media="(min-width: 501px) and (max-width: 768px)" fetchpriority="high"><link rel="preload" as="image" href="https://variance.pl/wp-content/uploads/2024/05/Kwiatowy-Ksiezyc-1348x900.webp" media="(min-width: 768.1px)" fetchpriority="high">
<title>lcp_responsive_bg</title><link rel="preload" data-rocket-preload as="image" href="https://variance.pl/wp-content/uploads/2024/05/Kwiatowy-Ksiezyc-400x600.webp" media="(max-width: 500px)" fetchpriority="high"><link rel="preload" data-rocket-preload as="image" href="https://variance.pl/wp-content/uploads/2024/05/Kwiatowy-Ksiezyc-768x513.webp" media="(min-width: 501px) and (max-width: 768px)" fetchpriority="high"><link rel="preload" data-rocket-preload as="image" href="https://variance.pl/wp-content/uploads/2024/05/Kwiatowy-Ksiezyc-1348x900.webp" media="(min-width: 768.1px)" fetchpriority="high">
</head>
<body>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<html>
<head>
<?php wp_head() ?>
<title>lcp_responsive_bg</title><link rel="preload" as="image" href="wolf.jpg" imagesrcset="wolf_400px.jpg 400w, wolf_800px.jpg 800w, wolf_1600px.jpg 1600w" imagesizes="50vw" fetchpriority="high">
<title>lcp_responsive_bg</title><link rel="preload" data-rocket-preload as="image" href="wolf.jpg" imagesrcset="wolf_400px.jpg 400w, wolf_800px.jpg 800w, wolf_1600px.jpg 1600w" imagesizes="50vw" fetchpriority="high">
</head>
<body>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<html>
<head>
<?php wp_head() ?>
<title>lcp_single_bg</title><link rel="preload" as="image" href="http://example.org/wp-content/rocket-test-data/images/lcp/testavif.avif" fetchpriority="high">
<title>lcp_single_bg</title><link rel="preload" data-rocket-preload as="image" href="http://example.org/wp-content/rocket-test-data/images/lcp/testavif.avif" fetchpriority="high">
<style>
.img-single-css-background-image{
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<head>
<title>Relative test</title><link rel="preload" as="image" href="http://example.org/wp-content/uploads/sample_relative_image.jpg" fetchpriority="high">
<title>Relative test</title><link rel="preload" data-rocket-preload as="image" href="http://example.org/wp-content/uploads/sample_relative_image.jpg" fetchpriority="high">
</head>
<body>
<img Src="/wp-content/uploads/sample_relative_image.jpg" alt="Relative url" FetchPriority>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<head>
<title>Relative test</title><link rel="preload" as="image" href="http://example.org/wp-content/uploads/sample_relative_image.jpg" fetchpriority="high">
<title>Relative test</title><link rel="preload" data-rocket-preload as="image" href="http://example.org/wp-content/uploads/sample_relative_image.jpg" fetchpriority="high">
</head>
<body>
<!--<img src="/wp-content/uploads/duplicate.jpg" alt="Duplicate image">-->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<head>
<title>Test</title><link rel="preload" as="image" href="http://example.org/wp-content/uploads/image.jpg" fetchpriority="high">
<title>Test</title><link rel="preload" data-rocket-preload as="image" href="http://example.org/wp-content/uploads/image.jpg" fetchpriority="high">
<style>
.test{
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<head>
<title>Test</title><link rel="preload" as="image" href="http://example.org/wp-content/uploads/image.jpg" fetchpriority="high">
<title>Test</title><link rel="preload" data-rocket-preload as="image" href="http://example.org/wp-content/uploads/image.jpg" fetchpriority="high">
</head>
<body>
<img fetchpriority="high" src="http://example.org/wp-content/uploads/image.jpg">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<head>
<title>Test</title><link rel="preload" as="image" href="http://example.org/wp-content/uploads/image.jpg" fetchpriority="high">
<title>Test</title><link rel="preload" data-rocket-preload as="image" href="http://example.org/wp-content/uploads/image.jpg" fetchpriority="high">
</head>
<body>
<picture>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<head>
<title>Test</title><link rel="preload" as="image" href="http://example.org/wp-content/uploads/image.jpg" fetchpriority="high">
<title>Test</title><link rel="preload" data-rocket-preload as="image" href="http://example.org/wp-content/uploads/image.jpg" fetchpriority="high">
</head>
<body>
</body>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<head>
<title>Absolute url test</title><link rel="preload" as="image" href="http://example.com/wp-content/uploads/sample_absolute_image.jpg" fetchpriority="high">
<title>Absolute url test</title><link rel="preload" data-rocket-preload as="image" href="http://example.com/wp-content/uploads/sample_absolute_image.jpg" fetchpriority="high">
</head>
<body>
<img fetchpriority="high" src="http://example.com/wp-content/uploads/sample_absolute_image.jpg" alt="Absolute url">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<head>
<title>Relative test</title><link rel="preload" as="image" href="http://example.org/wp-content/uploads/sample_relative_image.jpg" fetchpriority="high">
<title>Relative test</title><link rel="preload" data-rocket-preload as="image" href="http://example.org/wp-content/uploads/sample_relative_image.jpg" fetchpriority="high">
</head>
<body>
<img fetchpriority="high" SRC="/wp-content/uploads/sample_relative_image.jpg" alt="Relative url">
Expand Down
Loading
Loading