-
Notifications
You must be signed in to change notification settings - Fork 839
PWA: Adds lazy image loading module #8093
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no longer a TODO
0d74c6e to
3982c84
Compare
|
At this point, things are functional in IE11 and Edge as well as Chrome. Todos:
|
|
@mjangda mentioned that we should consider pulling updates from here: |
f141a80 to
f523351
Compare
|
At this point, we are functional back to IE9 as well as other browsers. Known issues/questions at this point are:
Note: I tried very hard to not have jQuery as a dependency here. But, since the |
| @@ -0,0 +1,134 @@ | |||
| /* globals IntersectionObserver, jQuery */ | |||
|
|
|||
| /** | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the license for the polyfill need to go here? Also, I'd like to keep the polyfill in this same file to minimize network requests. It bails early if it detects IntersectionObserver is in window, so it shouldn't cause issues. If we leave it here though, should me unminify it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just include the polyfill licence in Jetpack license, or somewhere like that. I don't think we need to serve it to the browser.
| * @param string The URL to the placeholder image | ||
| */ | ||
| return apply_filters( | ||
| 'lazyload_images_placeholder_image', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to use the same filters as the Lazy Load plugin to allow for easy updating for VIP and other users. Should we use something else though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am torn. I guess we should keep them the same though. Sites switching from the existing plugin will experience brokenness/regressions otherwise, and people switching from other plugins won't care. Developers might think it's weird that we didn't prefix it with jetpack_, but only for about 5 seconds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to leave a comment why we choose not to prefix it with jetpack_
Minifying twice shouldn't break things. However, let's put this in un-minified so that people can read the code, and so that the unminified version can include its own license.
We can add them later if we want. I don't want to have this as a super-long-lived PR, and I think if we're confident this works it would be good to get it merged so we can get it in people's hands ASAP. |
|
Is there any way to only load the intersection observer if it's necessary? |
gravityrail
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome
|
In talking to @oskosk, we realized that the Apache 2.0 license on the current IntersectionObserver polyfill is not compatible with GPLv2. So, I'll need to fix that before we can merge. @gravityrail's did a search and found an MIT-licenses IntersectionObserver that I'll test tomorrow: https://github.com/que-etc/intersection-observer-polyfill |
fa7622a to
3a9aaeb
Compare
|
I've now updated the IntersectionObserver polyfill to use the above-linked MIT project. This can now be reviewed again. |
…nline the polyfill
1aef1c6 to
4b007f0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Tested well even in combination with the mentioned plugin. The issue when photon is active, remains, but it's a matter for another PR
* Changelog 5.6: create base for changelog. * Update changelog with 5.5.1 info. * Changelog: add #7930 and #8238 * Changelog: add #8076 * Changelog: add #8100 * Changelog: add #8117 * Changelog: add #8141 * Changelog: add #8143 * Changelog: add #8147 * Changelog: add #8149 * Changelog: add #8153 * Changelog: add #8173 * Changelog: add #8184 * Changelog: add #8196 * Changelog: add #8199 * Changelog: add #8093 * Changelog: add #8171 * Changelog: add #8182 * Changelog: add #8202, #8222 * Changelog: add #8228 * Changelog: add #8240 * Changelog: add #8251 * remove AL card change
Will help speed by minimizing the number of images we download when the page is first viewed.
This plugin is largely based on the Lazy Load plugin, but has been updated to make use of IntersectionObserver. IntersectionObserver does not have great browser support. But, we are using a polyfill that will add the necessary functionality.
I have several questions, which are listed in this comment, mostly around attribution and how we should load the polyfill.
Besides that, this PR should be ready for some review and testing.
To test:
$site.com/wp-admin/admin.php?page=jetpack_modulesand enable the Lazy Images module