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

Adjustments to lazyloadable images #787

Merged
merged 4 commits into from Oct 5, 2020
Merged

Conversation

gmetais
Copy link
Contributor

@gmetais gmetais commented Oct 5, 2020

This is a couple of fixes for some cases where the lazyloadableImages module was not accurate.

Part 1:
The new engine now interprets <picture> tags. I've changed the way we read URLs in the lazyloadableImages module, so that it can pick the <source> URL that is actually loaded by the browser. Same for <img> tags with a srcset attribute, this pull request picks the URL that is actually loaded.

Part 2:
On some websites, images are loaded very lately, for example in a slider or a carousel. I can see they are loaded in the requests list (when using the --wait-for-network-idle option), but they don't appear in the "lazyloadable" list. I've changed when images are analyzed, switching from window.onLoad to window.onBeforeUnload.

See you!

@macbre macbre added the bug label Oct 5, 2020
@macbre macbre added this to the v2.0 - headless Chromium milestone Oct 5, 2020
@@ -246,6 +246,11 @@ Browser.prototype.visit = (url, waitUntil, timeout) => {

// we're done
Browser.prototype.close = async () => {
// Allow the beforeunload event to be executed
// https://github.com/puppeteer/puppeteer/blob/v1.11.0/docs/api.md#pagecloseoptions
if (this.page) await this.page.close({runBeforeUnload: true});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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

Successfully merging this pull request may close these issues.

None yet

2 participants