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

CSS selectors like :where() are not included in generated critical css #356

Open
batbattur opened this issue May 11, 2023 · 1 comment
Open

Comments

@batbattur
Copy link

Description

CSS selectors like the following are not getting included in the generated critical css file: :where(), :has(), :not(), :host(), :root() and possibly others.

Reproduction steps

I have the following files: index.html, styles.css, and the script used to run penthouse testing.js.
Running the penthouse with node testing.js produces outfile.css with nothing.

index.html:

<!DOCTYPE html>
<html>
<head>
	<title>:where() Selector Example</title>
	<link rel="stylesheet" href="styles.css">
</head>
<body>
	<h1>This is a heading</h1>
	<p>This is a paragraph</p>
	<ul>
		<li>List item 1</li>
		<li>List item 2</li>
	</ul>
	<h2>Another heading</h2>
	<p>Another paragraph</p>
</body>
</html>

styles.css

:where(h1, h2, h3, h4, h5, h6) {
	color: blue;
	font-family: Arial, sans-serif;
}

:where(p, li) {
	font-size: 16px;
	line-height: 1.5;
}

The js script used to run penthouse: testing.js

#!/usr/bin/env node

const penthouse = require('penthouse')
const fs = require("fs");

penthouse({
  url: 'file:///<some path>/index.html',
  css: '/<some path>/styles.css'
})
.then(criticalCss => {
  // use the critical css
  fs.writeFileSync('outfile.css', criticalCss)
})

Question

Should these selectors be included in the generated critical CSS file If they are above the fold?

@batbattur
Copy link
Author

Found out that this was happening because of the older puppeteer version. Running with #347 checked out fixed the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant