Skip to content

Is there a way to load images dynamically in nextra? #3142

Answered by eliot-akira
Gitstar-OC asked this question in Q&A
Discussion options

You must be logged in to vote

lazy loading only the images which is in the viewport

This is a feature of the img element.

<img src='/example.jpg' loading=lazy />

Reference: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#loading

Now, how to add this attribute to all images on a page.. Every image in an MDX file gets transformed into an Image component provided by Next.js.

The Next.js Image component extends the HTML <img> element with features for automatic image optimization:
...

  • Faster Page Loads: Images are only loaded when they enter the viewport using native browser lazy loading, with optional blur-up placeholders.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Gitstar-OC
Comment options

Answer selected by Gitstar-OC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants