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

perf(image): replace js images lazy loading by html loading attribute #5816

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

Conversation

sad270
Copy link
Contributor

@sad270 sad270 commented Nov 4, 2023

Closes #2371

Changes proposed in this pull request:

  • Replace js image lazy loading by loading="lazy" html attribute
  • Add loading="lazy" on all rss content image if lazy-loading configuration is true (even if the "display_post is enabled)

How to test the feature manually:

  1. Enable Lazy loading from setting
  2. Open a feed with images
  3. Check if loading="lazy" attribute is set
  4. You can also open "Network" tab of your browser developer options and check if the feed images is only load when the feed is open, and on scroll.

Pull request checklist:

  • clear commit messages
  • code manually tested
  • unit tests written (optional if too hard)
  • documentation updated

Additional information can be found in the documentation.

@sad270 sad270 force-pushed the feat/replace-content-js-lazy-load-by-loading-attribute branch from 5b058a5 to 542f683 Compare November 4, 2023 16:51
@Alkarex Alkarex added this to the 1.23.0 milestone Nov 4, 2023
@Alkarex Alkarex added the UX User experience label Nov 4, 2023
],
return preg_replace(
'/<((?:img|iframe)[^>]+?)([^>]*)>/i',
'<$1 loading="lazy"$2>',
Copy link
Member

Choose a reason for hiding this comment

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

We need to check upstream that we filter out existing loading attributes (that might already be the case), to make sure we do not end up with two identical attributes, which would be invalid

@@ -15,7 +15,6 @@ echo htmlspecialchars(json_encode(array(
'auto_mark_scroll' => !!$mark['scroll'],
'auto_load_more' => !!FreshRSS_Context::$user_conf->auto_load_more,
'auto_actualize_feeds' => !!Minz_Session::param('actualize_feeds', false),
'does_lazyload' => !!FreshRSS_Context::$user_conf->lazyload ,
Copy link
Member

Choose a reason for hiding this comment

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

This removes the option of not having lazy loading, which is not good

Copy link
Member

@Alkarex Alkarex left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!
The use-case of not using lazy-loading must be preserved (descriptions of the need can be found in past issues, for instance on slow connections, to make sure all images are loaded before starting to read)

@Alkarex Alkarex modified the milestones: 1.23.0, 1.24.0 Nov 24, 2023
@Alkarex Alkarex modified the milestones: 1.24.0, 1.25.0 Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
UX User experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider using native loading="lazy"
2 participants