Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

187
Vistas
How to make infinite scroll on Next.js static page?

I'm making portfolio using Next.js and count of projects on page is big enough. I want to start loading images when they get into the current viewport. Such scenario works well with default placeholder prop of next/image.

I'm using custom placeholder (skeleton) component for my images (placeholder is hided when runs onLoadingComplete image prop). If I used SSR then algorithm is clear but with SSG I've reached a dead end.

Will be happy to any advices!

My image component code:

import Placeholder from './placeholder';

const ImageRenderer = ({ url, alt, layout, objFit, width, height }) => {
    const [isImageLoaded, setIsImageLoaded] = useState(false); // loading state

    return (
        <>
            {!isImageLoaded && <Placeholder />}
            <StyledImage
                src={url}
                alt={alt}
                width={width}
                height={height}
                layout={layout}
                objectFit={objFit}
                onLoadingComplete={() => setIsImageLoaded(true)} // runs when next/image is loaded
            />
        </>
    );
};

Placeholder is just div with higher z-index.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You can simply add loading="lazy" to your images. It is supported in modern browsers.

Update: For videos you can use preload="none".

about 4 years ago · Juan Pablo Isaza Denunciar

0

You should consider using next/image, which by default will only load images as they enter the viewport (you can control that via the lazyBoundary prop). SSG vs SSR does not affect this behavior.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda