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

core(tags-blocking-first-paint): ignore malformed link tags #15489

Merged
merged 2 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions cli/test/fixtures/dobetterweb/dbw_tester.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
<!-- Alternate stylesheets should not show in TagsBlockingFirstPaint artifact -->
<link rel="alternate stylesheet" href="./empty.css">

<!-- Malformed links should not show in TagsBlockingFirstPaint artifact -->
<link rel="stylesheet" href="">

<!-- FAIL: block rendering -->
<script src="./dbw_tester.js" id="dbw-tester-script"></script>

Expand Down
9 changes: 9 additions & 0 deletions cli/test/smokehouse/test-definitions/dobetterweb.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ const expectations = {
crossOrigin: null,
source: 'head',
},
{
rel: 'stylesheet',
href: 'http://localhost:10200/dobetterweb/dbw_tester.html',
hrefRaw: '',
hreflang: '',
as: '',
crossOrigin: null,
source: 'head',
},
{
rel: 'stylesheet',
href: 'http://localhost:10200/dobetterweb/dbw_tester.css?scriptActivated&delay=200',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ async function collectTagsThatBlockFirstPaint() {
/** @type {Array<LinkTag>} */
const linkTags = [...document.querySelectorAll('link')]
.filter(linkTag => {
// Ignore malformed links with no href (e.g. `<link rel="stylesheet" href="">`)
// The resolved `linkTag.href` will be the main document, but the main document
// should never be render blocking.
if (!linkTag.getAttribute('href')) return false;

// Filter stylesheet/HTML imports that block rendering.
// https://www.igvita.com/2012/06/14/debunking-responsive-css-performance-myths/
// https://www.w3.org/TR/html-imports/#dfn-import-async-attribute
Expand Down
Loading