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

Lazy Images: remove from Jetpack plugin #33782

Merged
merged 2 commits into from
Oct 25, 2023
Merged

Lazy Images: remove from Jetpack plugin #33782

merged 2 commits into from
Oct 25, 2023

Conversation

jeherve
Copy link
Member

@jeherve jeherve commented Oct 25, 2023

Fixes #33171

Proposed changes:

We deprecated the feature and issued notices to our users still using it in #33208. It is now time to remove it entirely.

  • If the module is still enabled, we disable it.
  • We do not display the feature in any of our UI elements anymore.
  • We declare the file as deprecated, so we can safely remove it in a future version of the plugin.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Let's also take that opportunity to close related issues:

Fixes #10016
Fixes #9827
Fixes #24002
Fixes #9043
Fixes #11054
Fixes #8905
Fixes #17640
Fixes #15073
Fixes #16421
Fixes #8879
Fixes #9509
Fixes #9974
Fixes #9896
Fixes #8917
Fixes #10046
Fixes #8897
Fixes #9929
Fixes #9595
Fixes #10606
Fixes #12344
Fixes #10607
Fixes #25659
Fixes #29585
Fixes #14191
Fixes #13518
Fixes #10707
Fixes #8996
Fixes #8773
Fixes #8281
Fixes #14161
Fixes #31877
Fixes #14281

Jetpack product discussion

Does this pull request change what data or activity we track or use?

  • Yes, it removes all Lazy Image links from the UI, and thus the attached tracking disappears with them.

Testing instructions:

  • You can start with a site running trunk, using the Lazy Images module: connect your site to WordPress.com, and in WP CLI, enable the module (you cannot enable it via the UI anymore): wp jetpack module activate lazy-images
  • Switch to this branch.
  • Go to Jetpack > Settings > Performance
    • You should not see any mentions of Lazy Images anymore.
  • Go to Jetpack > Settings > Modules
    • No mention of the feature there either.
  • Back to the CLI, run wp jetpack module list
    • No mention of the feature there either.

Fixes #33171

We deprecated the feature and issued notices to our users still using it in #33208. It is now time to remove it entirely.

- If the module is still enabled, we disable it.
- We do not display the feature in any of our UI elements anymore.
- We declare the file as deprecated, so we can safely remove it in a future version of the plugin.
@jeherve jeherve added this to the jetpack/12.8 milestone Oct 25, 2023
@jeherve jeherve requested a review from a team October 25, 2023 15:59
@jeherve jeherve self-assigned this Oct 25, 2023
@jeherve jeherve enabled auto-merge (squash) October 25, 2023 15:59
@github-actions
Copy link
Contributor

github-actions bot commented Oct 25, 2023

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WordPress.com Simple site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin, and enable the rm/lazy-images-jetpack branch.

  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack rm/lazy-images-jetpack
    

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions bot added [Block] Slideshow [Feature] Theme Tools [Focus] Compatibility Ensuring our products play well with third-parties [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests Admin Page React-powered dashboard under the Jetpack menu E2E Tests labels Oct 25, 2023
@github-actions
Copy link
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team Review" label and ask someone from your team review the code. Once reviewed, it can then be merged.
If you need an extra review from someone familiar with the codebase, you can update the labels from "[Status] Needs Team Review" to "[Status] Needs Review", and in that case Jetpack Approvers will do a final review of your PR.


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen daily.
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly. The next release is scheduled for November 7, 2023 (scheduled code freeze on October 30, 2023).

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

Copy link
Contributor

@anomiex anomiex left a comment

Choose a reason for hiding this comment

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

Works as advertised.

I did a search looking for other references to lazy image loading. I suppose these things need to wait until it's removed from Boost too?

  • Image CDN package support for our lazy-images feature:
    • // Support Automattic's Lazy Load plugin.
      // Can't modify $tag yet as we need unadulterated version later.
      if ( preg_match( '#data-lazy-src=["\'](.+?)["\']#i', $images['img_tag'][ $index ], $lazy_load_src ) ) {
      $placeholder_src_orig = $src;
      $placeholder_src = $placeholder_src_orig;
      $src_orig = $lazy_load_src[1];
      $src = $src_orig;
      } elseif ( preg_match( '#data-lazy-original=["\'](.+?)["\']#i', $images['img_tag'][ $index ], $lazy_load_src ) ) {
      $placeholder_src_orig = $src;
      $placeholder_src = $placeholder_src_orig;
      $src_orig = $lazy_load_src[1];
      $src = $src_orig;
      }
    • // If Lazy Load is in use, pass placeholder image through Photon.
      if ( isset( $placeholder_src ) && self::validate_image_url( $placeholder_src ) ) {
      $placeholder_src = Image_CDN_Core::cdn_url( $placeholder_src );
      if ( $placeholder_src !== $placeholder_src_orig ) {
      $new_tag = str_replace( $placeholder_src_orig, esc_url( $placeholder_src ), $new_tag );
      }
      unset( $placeholder_src );
      }
    • // Support for lazy loading: if there is a lazy-src attribute and it's value
      // is not the same as the current src we should wait until the image load event
      const lazySrc = this.getAttribute( 'data-lazy-src' );
      if ( lazySrc && this.src !== lazySrc ) {
      this.addEventListener( 'onload', recalculate );
      return;
      }
  • Adding "abandoned" to projects/packages/lazy-images/composer.json, and an appropriate notice in the readme.
  • Boost-related reference in my-jetpack:
    array(
    'name' => __( 'Lazy image loading', 'jetpack-my-jetpack' ),
    'info' => array(
    'content' => __(
    'Improve page loading speed by only loading images when they are required.',
    'jetpack-my-jetpack'
    ),
    'link' => array(
    'id' => 'jetpack-boost-lazy-load',
    'title' => 'web.dev',
    ),
    ),
    'tiers' => array(
    self::FREE_TIER_SLUG => array( 'included' => true ),
    self::UPGRADED_TIER_SLUG => array( 'included' => true ),
    ),
    ),
  • Boost-related reference at
    __( 'Lazy image loading and site performance scores', 'jetpack' ),

Also I wonder whether https://github.com/Automattic/jetpack/blob/rm/lazy-images-jetpack/projects/packages/search/src/instant-search/components/photon-image.jsx, which looks like it does its own lazy loading, should be changed to just use loading="lazy" too.

@jeherve jeherve merged commit 0c9d898 into trunk Oct 25, 2023
54 of 55 checks passed
@jeherve jeherve deleted the rm/lazy-images-jetpack branch October 25, 2023 20:08
@github-actions github-actions bot removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. [Status] Needs Team Review labels Oct 25, 2023
@jeherve
Copy link
Member Author

jeherve commented Oct 26, 2023

I suppose these things need to wait until it's removed from Boost too?

Yes, once we do not use the Lazy Images package anywhere anymore, we'll be able to completely remove everything and properly deprecate the package. This is tracked in the primary issue: #33048.

Also I wonder whether rm/lazy-images-jetpack/projects/packages/search/src/instant-search/components/photon-image.jsx, which looks like it does its own lazy loading, should be changed to just use loading="lazy" too.

That's a good point. @jsnmoon Looks like you worked on #19269 back in the day. Do you think we could remove this in favor of the loading attribute now?

@jsnmoon
Copy link
Member

jsnmoon commented Oct 26, 2023

That's a good point. @jsnmoon Looks like you worked on #19269 back in the day. Do you think we could remove this in favor of the loading attribute now?

Yup, that sounds good!

@jeherve jeherve added the [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. label Oct 27, 2023
jeherve added a commit that referenced this pull request Mar 4, 2024
The module was deprecated in #33782. We can now safely remove the module from the plugin.
@jeherve jeherve mentioned this pull request Mar 4, 2024
3 tasks
jeherve added a commit that referenced this pull request Mar 4, 2024
The module was deprecated in #33782. We can now safely remove the module from the plugin.
anomiex added a commit that referenced this pull request Jul 18, 2024
Now that we require WordPress 6.5, we can remove any
backwards-compatibility checks for folks that run WP 6.4.

I also cleaned up some older stuff while I was looking.

* js-packages/components: Remove a deprecation kept for 6.4 compat.
* packages/jetpack-mu-wpcom: Simplify a test.
* plugins/jetpack: Remove unnecessary `version_compare()` calls, assume
  WP 6.5+.
* plugins/jetpack: Remove a check for us being Jetpack >=5.3.
* plugins/jetpack: Remove some code checking for `JSON_BIGINT_AS_STRING`
  support, which was added in PHP 5.4.
* plugins/jetpack: Address some `@todo` comments calling for action once
  WP 6.5 is the minimum.
* plugins/jetpack: Remove support code for a feature removed in #33782
* plugins/wpcomsh: Remove unnecessary `version_compare()` calls, assume
  WP 6.5+.
* plugins/wpcomsh: Remove some checks for old Jetpack versions.
* plugins/wpcomsh: Remove a polyfill for WordPress before 5.4.
* cli: Update some code for node 20.1+.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment