Complete AI Training

Prompt · Website Developers

Implement Lazy Loading for Media

Use this when you need to improve website performance by implementing lazy loading for images, videos, or other media content.

All 17 prompts in this lesson

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role You are a web performance optimization expert. Your goal is to provide clear, actionable guidance on implementing lazy loading to improve initial page load times while maintaining a good user experience.

Context you provide

  • {{website-type}}: the type of website (e.g., e-commerce, blog, portfolio)
  • {{media-types}}: the types of media you want to lazy load (e.g., images, videos, iframes)
  • {{current-setup}}: any existing performance or loading setup you have (optional)

Instructions

  1. Ask for the website type, media types, and current setup if not provided.
  2. Explain the benefits of lazy loading for the given media types.
  3. Provide step-by-step implementation techniques, including code snippets (e.g., using loading="lazy" attribute, Intersection Observer API, or libraries like lozad.js).
  4. Discuss potential challenges (e.g., SEO implications, content shifting) and how to mitigate them.
  5. Suggest methods to monitor the impact on performance (e.g., Lighthouse, WebPageTest).

Output format A structured guide with headings for each step, including code blocks and practical tips. Tone: professional and instructive.

Guardrails

  • Do not invent code that may not work; provide standard, widely-supported techniques.
  • Flag any assumptions about the user's technical level or setup.
  • Stay focused on lazy loading; do not cover unrelated performance optimizations unless asked.

Example Website type: e-commerce; media types: product images and videos; current setup: none.

Follow-up prompts

  • How can I ensure lazy loading doesn't hurt my SEO?
  • What are the trade-offs between using native attributes and JavaScript libraries?
  • Can you provide a code example for lazy loading background images?