-
Notifications
You must be signed in to change notification settings - Fork 35
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
Take elements into account which do appear on scrolling #392
Comments
I'm not convinced. If you really want to depend on scrolling, it would be best if you can pass in a callable (that returns a promise) that does things to the DOM before the critical CSS is captured. In your case, it would be to scroll a bit. In someone else's case it might to be click some button. So if you can come up with an optional callable that would be awesome. And a lot of people would appreciate your contribution. |
The other thing I would recommend is to wrap up your deployment with minimal CSS such that the rest of the CSS is loaded between the initial load and the first scrolling. With the right lazy loading, no human would be able to be fast enough to scroll down and see unstyled content. |
Somewhat related to this... Sticky or fixed navigation bars that appear after scrolling are also missed by minimalcss. Is there a way around this? I've been adding the sticky css class to my whitelist, but each website is different and uses different class names. |
There is no known workaround other than you should only rely on the minimal CSS to be that before somebody scrolls. I.e. navigating with no hands :) minimalcss
.minimize({ url: 'https://example.com/' }, interact: (document) => {
// Scroll down a bit so that the sticky navbar starts to appear
document.scrollTo(300);
})
.then(result => {
console.log('OUTPUT', result.finalCss.length, result.finalCss);
})
.catch(error => {
console.error(`Failed the minimize CSS: ${error}`);
}); The thing that scares me is; you might now need to take 2 "snapshots". One when you haven't scrolled and one when you've scrolled down a bit. In the end, I would recommend that you use the minimal css to put that into a |
I tried the scrollTo statement but I didn't get a different css output. Here's another example: https://metrolighting.ca/lighting-automation-solutions/ If you scroll down the page, you'll see an image slider. When I run minimalcss, the following selectors are missing: button styling: And button arrows: Is this related to animation not being captured unless scroll event is somehow captured? |
Hi!
Currently elements which appear only after scrolling (like in many one-pager) are not taken into account when css is generated.
Regarding to https://github.com/Zrce/puppeteer-coverage-report-test/blob/master/index.js
I would like to see that an option for autoscroll is added
const autoScroll = async (page) => { await page.evaluate(async () => { await new Promise((resolve, reject) => { console.log("start scrolling"); var totalHeight = 0; var distance = 100; var timer = setInterval(() => { var scrollHeight = document.body.scrollHeight; window.scrollBy(0, distance); totalHeight += distance; if (totalHeight >= scrollHeight) { clearInterval(timer); resolve(); } }, 100); }); }); }
May I create a pull request for that?
The text was updated successfully, but these errors were encountered: