-
Notifications
You must be signed in to change notification settings - Fork 1
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
Defer non-crititcal CSS #1
Comments
I created a POC to run the penthouse basic example inner a Docker container. Start a node container
Install ChromeBased on https://github.com/buildkite/docker-puppeteer/blob/master/Dockerfile
Add penthouse and puppeteer
Commit the image to checkpoint and use on the future
Run the POC
Paste this script: const puppeteer = require('puppeteer')
const penthouse = require('penthouse')
// Based on https://github.com/pocketjoso/penthouse/issues/311
browser = puppeteer.launch({
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-dev-shm-usage',
'--window-size=1920,1200',
],
defaultViewport: {
width: 1920,
height: 1200,
},
})
// Based on https://github.com/pocketjoso/penthouse#basic-example
penthouse({
url: 'http://google.com',
cssString: 'body { color: red }',
puppeteer: {
getBrowser: () => browser,
}
}).then(criticalCss => {
console.log(criticalCss)
}) Press
|
How to take a sceenshot using Puppeteer
Press ctrl + D to run the script. The screenshot will be on project root |
It was created the branch penthouse-poc to facilitate run the POC. The commands to build and run are:
Expected result:
|
Added server to return the critical CSS and to be processed by WordPress (0aa0f94, db32882).
|
CSS files are render-blocking resource. They impact the page load. So, if the CSS resources is delayed, the page is loaded faster.
The challenge on this technique is to load the critical path CSS (above the fold) style preloaded. If it isn't done, we have a big trouble with Cumulative Layout Shift because the first load will be done without any style.
penthouse is a tool that allow you generate critical path CSS. Supplying the URL and the CSS content of the file, it is possible to get the critical path CSS. If shipped on the environment, it is possible generate the critical path for tests purpose.
Oportunity/Diagnotiscs:
Reference
The text was updated successfully, but these errors were encountered: