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

Improve Page Load Performance by Deferring Scripts and Lazy Loading Images ✈️ #1177

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sanjaiyan-dev
Copy link

Hi, I believe this pull request implements small but valuable performance improvements and follows best web practices.
The script tag is now run with the defer attribute, which improves performance. For more information, please see https://web.dev/articles/efficiently-load-third-party-javascript#defer.
We've added the loading attribute to images below the viewport, enabling lazy loading and optimizing network usage. For more information, please refer to https://web.dev/articles/browser-level-image-lazy-loading#the_loading_attribute.

<a href="https://twitter.com/rustlang" target="_blank" rel="noopener" alt="twitter link"><img decoding="async" loading="lazy" src="{{root}}images/twitter.svg" alt="twitter logo" title="Twitter"/></a>
<a href="https://www.youtube.com/channel/UCaYhcUwRBNscFNUKTjgPFiA" target="_blank" rel="noopener" alt="youtube link"><img decoding="async" loading="lazy" style="padding-top: 6px; padding-bottom:6px" src="{{root}}images/youtube.svg" alt="youtube logo" title="YouTube"/></a>
<a href="https://discord.gg/rust-lang" target="_blank" rel="noopener" alt="discord link"><img decoding="async" loading="lazy" src="{{root}}images/discord.svg" alt="discord logo" title="Discord"/></a>
<a href="https://github.com/rust-lang" target="_blank" rel="noopener" alt="github link"><img decoding="async" loading="lazy" src="{{root}}images/github.svg" alt="github logo" title="GitHub"/></a>
Copy link
Contributor

Choose a reason for hiding this comment

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

From MDN:

Note: Images with loading set to lazy will never be loaded if they do not intersect a visible part of an element, even if loading them would change that as unloaded images have a width and height of 0. Putting width and height on lazyloaded images fixes this issue [...]

This wording is for me a bit confusing so I'm not completely sure about what this exactly implies for a website like the Rust blog. Just wanted to bring this here in case it's useful.

Copy link
Author

Choose a reason for hiding this comment

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

I thought setting the image under the user viewport not to be fetched until it's visible, which can improve network usage on the client and lead to faster website loading. Users won't download unnecessary images at the bottom unless they scroll to that section, saving network usage and ensuring the website loads faster. Here's the Google article: Browser-level image lazy loading.

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.

None yet

2 participants