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

#2635, #3290: Add WebP conversion step to all included image styles. #3418

Merged
merged 4 commits into from
Jun 28, 2024

Conversation

joeparsons
Copy link
Member

@joeparsons joeparsons commented May 15, 2024

Description

Adds webp conversion step to all included image styles, similar to how Drupal core updated all of its included image styles. See: https://www.drupal.org/node/3421405

Release notes

This release adds a WebP conversion step to all image styles provided by AZ Quickstart and [Drupal core](https://www.drupal.org/node/3421405). A [patch for Drupal core](https://www.drupal.org/project/drupal/issues/3310963) has also been included that the adds a directive to the `.htaccess` file included with Drupal core to ensure the WebP image MIME type is supported.  Sites hosted on Apache web servers may need to [update their .htaccess files](https://www.drupal.org/node/3456338) to take advantage of this improvement.

Related issues

#2635
#3290

How to test

Media images / image fields should be rendered as WebP files.

Types of changes

Arizona Quickstart (install profile, custom modules, custom theme)

  • Patch release changes
    • Bug fix
    • Accessibility, performance, or security improvement
    • Critical institutional link or brand change
    • Adding experimental module
    • Update experimental module
  • Minor release changes
    • New feature
    • Breaking or visual change to existing behavior
    • Upgrade experimental module to stable
    • Enable existing module by default or database update
    • Non-critical brand change
    • New internal API or API improvement with backwards compatibility
    • Risky or disruptive cleanup to comply with coding standards
    • High-risk or disruptive change (requires upgrade path, risks regression, etc.)
  • Other or unknown
    • Other or unknown

Drupal core

  • Patch release changes
    • Security update
    • Patch level release (non-security bug-fix release)
    • Patch removal that's no longer necessary
  • Minor release changes
    • Major or minor level update
  • Other or unknown
    • Other or unknown

Drupal contrib projects

  • Patch release changes
    • Security update
    • Patch or minor level update
    • Add new module
    • Patch removal that's no longer necessary
  • Minor release changes
    • Major level update
  • Other or unknown
    • Other or unknown

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@joeparsons joeparsons added enhancement New feature or request 2.11.x only labels May 15, 2024
@joeparsons joeparsons self-assigned this May 15, 2024
@joeparsons joeparsons requested a review from a team as a code owner May 15, 2024 00:21
@joeparsons joeparsons changed the title #2335, #3290: Add webp conversion step to all included image styles. #2335, #3290: Add WebP conversion step to all included image styles. May 15, 2024
@joeparsons joeparsons linked an issue May 15, 2024 that may be closed by this pull request
@trackleft trackleft requested a review from HenryzGreenberg May 15, 2024 16:27
trackleft
trackleft previously approved these changes May 15, 2024
Copy link
Member

@trackleft trackleft left a comment

Choose a reason for hiding this comment

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

LGTM, I tested to see how much this reduced the size of certain pages as well but didn't see a drastic improvement.

@HenryzGreenberg
Copy link

I want to run a comparison between JPG and WEBP Versions of the same page:
JPG: https://7b5e2985-cedf-4a13-ab91-3a35916c835d--pr-3418.probo.build/pages/photo-galleries
WebP: https://7b5e2985-cedf-4a13-ab91-3a35916c835d--pr-3418.probo.build/pages/photo-galleries-webp

However, when i upload images they still render as .jpg. Please Advise. What can we do here?
//H

@joeparsons
Copy link
Member Author

Possibly related Drupal core issue: https://www.drupal.org/project/drupal/issues/3413632

@joeparsons
Copy link
Member Author

I want to run a comparison between JPG and WEBP Versions of the same page: JPG: https://7b5e2985-cedf-4a13-ab91-3a35916c835d--pr-3418.probo.build/pages/photo-galleries WebP: https://7b5e2985-cedf-4a13-ab91-3a35916c835d--pr-3418.probo.build/pages/photo-galleries-webp

However, when i upload images they still render as .jpg. Please Advise. What can we do here? //H

Hi @HenryzGreenberg. Thanks for testing! It looks like there is an issue with the web server configuration on ProboCI that is preventing the correct MIME type for WebP images from getting sent to web browsers.

I've applied this PR's changes to a dev version of an existing site (I'll DM you the details) where this issues doesn't seem to exist.

@joeparsons
Copy link
Member Author

Found an Apache-specific RTBC core issue/patch for the mime type issue:
https://www.drupal.org/project/drupal/issues/3310963

@joeparsons
Copy link
Member Author

joeparsons commented May 17, 2024

2024-05-17

  • We should test on IIS somehow
  • We should verify that there aren't other Apache edge cases (e.g. different Apache module names) that aren't covered by the htaccess patch
  • We should also do some lighthouse testing to see how much difference this change makes

@HenryzGreenberg
Copy link

HenryzGreenberg commented May 17, 2024

page with jpg.pdf
page with webp.pdf

I ran both sites through Lighthouse as a rudimentary test: JPG vs. WEBP

Performance Metrics

Metric JPG WEBP Difference
Performance Score 67 74 +7
First Contentful Paint 2.7s 1.7s -1.0s
Largest Contentful Paint 2.8s 2.4s -0.4s
Speed Index 3.9s 3.3s -0.6s
Total Blocking Time 0ms 0ms 0ms
Cumulative Layout Shift 0.003 0.021 +0.018

General Observations

  • Performance: The WEBP version shows improvement in performance metrics, particularly in First Contentful Paint and Largest Contentful Paint.
  • Accessibility: Both versions score equally high, indicating robust accessibility.
  • Best Practices: Slightly lower for WEBP, (potentially due to differences in handling resources)
  • SEO: Both versions perform equally well.

While the test was only looking at jpg vs Webp performance it did move the needle slightly. It looks like there are other recommendations from Lighthouse that would further move the needle:

  1. Prioritize performance optimizations identified for both versions, such as eliminating render-blocking resources and minifying JavaScript.
  2. Leverage the WEBP format for its better performance metrics, particularly for reducing initial load times. <-- In Progress
  3. Reduce unused CSS and JavaScript for the WEBP version to further enhance performance.

Grain of Salt
I do think this is a step in the right direction but also I want to be sure development time is used wisely. I ran the test multiple times and each time got difference performance scores for both websites. In some cases, the Jpg version out performed the Webp version. I know there are tons of variables that can impact score such as network conditions, server performance, and the device used during the test. Even slight differences in these factors can lead to varying scores. I'd be interested to see what scores other see and perhaps get an average vs relying on just the report here.

@trackleft
Copy link
Member

@joeparsons
Copy link
Member Author

@joeparsons joeparsons changed the title #2335, #3290: Add WebP conversion step to all included image styles. #2635, #3290: Add WebP conversion step to all included image styles. Jun 5, 2024
@trackleft trackleft merged commit 88969df into main Jun 28, 2024
15 checks passed
@trackleft trackleft deleted the issue/2635 branch June 28, 2024 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Optimize Images and Media
4 participants