-
Notifications
You must be signed in to change notification settings - Fork 373
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
Migrate to headless Chrome? #229
Comments
idea of having css extracted with the help of coverage tool is really good as I guess that is what lighthouse uses. Also users rely on it as well. Although what happens to dynamic classnames? |
To be honest, I'm still somewhat skeptical of the value of code coverage tooling that doesn't include some form of UI hit-testing. That said, even today tools like |
I think it's worth a try. We should give it a shot on a separate branch to see how far we get. |
Don't we have snippets that generate critical css? If I'm not mistaken Chrome headless is able to inject scripts into pages - what if we combine the coverage report with those snippets? |
Just FYI I'm now looking to migrate Penthouse to headless chrome, so if you wait another ~ 2 weeks you can get this migration without any changes to |
@pocketjoso Wow. That's...pretty incredible :) Thanks for keeping an eye on the repo and for letting us know! That'll save a whole lot of time! We really appreciate you working on that migration 🎉 🍰 |
I have a headless chrome version of Penthouse with feature parity now, just fiddling with support for Linux etc - if you want to play with it it's available on the |
@pocketjoso: Thats awesome! Thanks for pushing things forward :) |
@pocketjoso: That's super cool. Will try it on a different branch and test it. |
I will be working on it in a separate branch in my fork. |
So let me get it. Is there a way we can use Critical with headless chrome now? ps: I am using headless Chrome any chance I get - it feels NOT dirty, fast and overall awesome. |
@phaistonian maybe you can just manually replace the penthouse lib in your node_modules with the one from |
@bezoerb @addyosmani and others: I will release Penthouse 1.0 this week (using chrome headless via Puppeteer); I've just been writing up a release blog post, and waiting for the Puppeteer team to close a few important bugs. 1.0 will be backwards compatible (except for that Puppeteer requires Node>=6.4.0), so this means you can upgrade without changing a thing! (the reason for the major version bump is more to mark Penthouse as stable tech). I recommend taking advantage of some changes though:
You can check the readme from the chrome headless Penthouse PR; it is mostly up to date and I will fix the remaining this week. As I've said before you can test this version on |
@pocketjoso Worked like charm! One little thing: I get this
all the time. It doe not affect the result, but it's a bit annoying. |
@phaistonian When I test the same in my local, two tests are failing for me. Here is the error log. |
So this is when running a lot of invocations in sequence, am I right? not in parallel? I'll look into it - thanks for testing both of you! |
Yup. |
Having used the Perhaps an "await" would do the trick :) |
@phaistonian Well the intention is to keep the browser instance running, to save some time and resources, but it currently closes as soon as the puppeteer task finishes - so before the next call happens when you run them in sequence. Sounds like there's some timing issue when the two calls happen close after each other (but not in parallel). |
\o/ This is amazing work, @pocketjoso. I can't thank you enough for the tireless work in getting Penthouse updated to use headless Chrome. I sit across from the Puppeteer team and if you find yourself blocked on anything at all, please feel free to ping and I'll have a chat with them.
I had been very curious to what extent backward compat would be maintained, but this sounds great.
Same here. This appears to occur during sequential invocations rather than running in parallel.
This is a good confidence booster. I believe @reznord is interested in working on
Whoa whoa whoa. That's actually very interesting. A part of my workflow when using |
So for full transparency @addyosmani, as I will disclose in the release post for Penthouse 1.0 (perhaps you know this already) - all my work on Penthouse is pretty much "funded" via the premium SASS service I built on top (https://criticalcss.com), which has been using image diffing since the start. It's also from where I've found most of the issues in Penthouse, and got the confidence that Penthouse works well, since it's used really heavily there. Will post another blog post about criticalcss.com too soon and my story about a successful open source revenue model for a "side project". :) |
And @addyosmani re sitting next to the Puppeteer team - that's awesome! You already found the most critical issue on my list (puppeteer/puppeteer#662).
Update: after debugging this today I found and resolved these regressions on my end - they were not coming from Puppeteer. 👍 I also understand that Puppeteer have other priorities than making execution as fast as possible with JS disabled, so hey perhaps this is known and intentional. All in all Chrome headless is lightyears faster than PhantomJS anyway. :) |
Finally @addyosmani I have been thinking about backwards compatibility, and the return value of Penthouse, per the discussion we had in London a while ago. I considered breaking the api to return an object with both the critical css and debug/error info as you asked for back then, but for this release I'm almost sold on going for compatibility, so I can get maximum adaptation as the release is just so much better than the current version. |
Update: Just published Doing final sanity testings, preparing to merge this into the @addyosmani and @bezoerb - I added 2 more points re changes critical should take up when adopting this new penthouse version (no need to promisify, and should be able to skip starting local servers for local files): #229 (comment) |
@pocketjoso everything works super awesome, except for this:
|
@reznord pushed one more commit that prevents rejecting the returned promise when Penthouse is called in And in the bigger picture would be great for |
@pocketjoso That's super awesome! Thanks for putting so much effort in this! I'm looking forward to make the suggested changes to critical this week. |
🎉 Penthouse 1.0 is here🎉: |
@pocketjoso Tests are currently failing for node 6. Seems like the current |
@bezoerb yeah commented in Penthouse repo. |
So? Almost there?:) |
@phaistonian: Yes :) we only need to fix node6 support |
Is there a PR to fix node6 tests? |
one step forward in #246 |
I found this Chrome extension: Critical CSS extractor Works good for my sites. |
* Bumped penthouse [#229] * adds puppeteer as dependency * Travis tweaks * Travis tweaks
How about a i.e |
v1.0.0 Released :) |
Now that headless Chrome is a thing and the DevTools support extracting unused CSS via the CSS/JS Code Coverage tool, it may be worth considering if
critical
would like to switch away from using PhantomJS over to this as part of a rewrite.CSS Code Coverage is available via the remote debugging protocol and my understanding is that we could programmatically use this to extract out CSS in a more accurate manner while maintaining a similar workflow to what
critical
supports today.Something that could be of value to consider is would this change be worth the effort? Would switching away from Phantom under the hood and over to the coverage model improve how close to ideal we're able to extract critical styles? or is the time we could spend doing this better spent addressing the existing edge-cases that come up in issues and smoothing those over instead?
The text was updated successfully, but these errors were encountered: