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

Blog post images should lazy load #568

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Brenosalv
Copy link
Collaborator

@Brenosalv Brenosalv commented Nov 15, 2024

Changes

  • Set loading attribute of the images to lazy in the patch @draftbox-co+gatsby-rehype-inline-images+1.0.2.patch.
  • Remove loading eager from imgSharp.

Tests / Screenshots

image

Prod env:
image

Dev env:
image

@Brenosalv Brenosalv added the tech debt This is a task that really only the engineers notice label Nov 15, 2024
@Brenosalv Brenosalv self-assigned this Nov 15, 2024
@Brenosalv Brenosalv linked an issue Nov 15, 2024 that may be closed by this pull request
const parsed = JSON.parse(imgdata);
return (
<GatsbyImage
className={className}
style={{ margin: '0 auto' }}
image={parsed}
alt={alt || 'Blog Post Image'}
loading="eager"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Default value is lazy.

const parsed = JSON.parse(imgdata);
return (
<GatsbyImage
className={className}
style={{ margin: '0 auto' }}
image={parsed}
alt={alt || 'Blog Post Image'}
loading="eager"
placeholder="none"
Copy link
Collaborator Author

@Brenosalv Brenosalv Nov 15, 2024

Choose a reason for hiding this comment

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

This prop placeholder does not exist in StaticImage component.

@Brenosalv Brenosalv marked this pull request as ready for review November 15, 2024 17:49
Copy link

Visit the preview URL for this PR (updated for commit 4371fcb):

https://estuary-marketing--pr568-brenosalv-tech-debt-72zpn15z.web.app

(expires Sun, 15 Dec 2024 19:05:21 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 76f6b095a0752e5d9c6c890267f9fdc3e392161e

@Brenosalv
Copy link
Collaborator Author

Brenosalv commented Nov 15, 2024

Images are not showing up with lazy loading:
image

They show up with eager loading.

@travjenkins
Copy link
Member

Forgot that I tried this once and ran into the same issue. I did not look into it at all though - so the fix is possibly simple.

@Brenosalv
Copy link
Collaborator Author

Forgot that I tried this once and ran into the same issue. I did not look into it at all though - so the fix is possibly simple.

To be honest, I’m not sure how to fix this yet. The lazy loading just works when we refresh the page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech debt This is a task that really only the engineers notice
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Blog post images are not lazy loading
2 participants