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

🚀 Accelerating Image Loads: Introducing decoding='async' for Images! 🌠 #112

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sanjaiyan-dev
Copy link

Adding the decoding="async" attribute for the img element.

Advantages and Benefits:

  1. Improved Page Load Speed: By setting the decoding attribute to "async", the browser will asynchronously decode the image, which means it will start rendering the visible parts of the page without waiting for the entire image to load. This results in faster page load times and a smoother user experience, especially for pages with multiple images.

  2. Reduced Network Latency: Asynchronous decoding reduces the time spent waiting for images to be fully downloaded, reducing the network latency. This is especially beneficial for users on slower internet connections or accessing the website from remote locations.

  3. Bandwidth Savings: Since the browser can render the visible parts of the page while decoding images asynchronously, it helps reduce the amount of data transferred over the network. This can lead to significant bandwidth savings for both the server and the end-users, making the website more efficient.

  4. Enhanced User Interaction: With faster page load times, users can interact with the content more quickly, leading to a better overall user experience. It also helps to lower bounce rates and increase user engagement on the website.

  5. Prioritization of Critical Resources: By using decoding="async", developers can prioritize other critical resources, such as scripts and stylesheets, while the browser handles the image decoding in the background. This can be particularly helpful in optimizing the loading of essential content on the page.

@sanjaiyan-dev sanjaiyan-dev marked this pull request as ready for review July 29, 2023 19:44
Copy link
Member

@lfades lfades left a comment

Choose a reason for hiding this comment

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

I think this change is fine but only for the tweet media images (the ones in the body of the tweet) and not for other images like the profile picture, which is very small in size and it's better we allow the browser to decide if it wants to do sync or async for it (that's what happens by default).

Did you test out this change in a deployment? I'm interested to know what is the actual impact of this change.

Removing `decoding="async"` for profile picture.
@sanjaiyan-dev
Copy link
Author

I think this change is fine but only for the tweet media images (the ones in the body of the tweet) and not for other images like the profile picture, which is very small in size and it's better we allow the browser to decide if it wants to do sync or async for it (that's what happens by default).

Did you test out this change in a deployment? I'm interested to know what is the actual impact of this change.

Hi, I removed the decoding attribute for profile picture.

Sorry, to be honest I couldn't run in benchmark tests. But I believe this have some amount of improvement and decoding attribute is used in Next js Image component too :)

@ryoppippi
Copy link

Asynchronous decoding is not a suitable option these days.
It is better to use the loading='lazy' option.

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

Successfully merging this pull request may close these issues.

4 participants