Complete AI Training

Prompt · Web Developers

Optimize Images for Performance

Use this when you need to optimize images to improve loading speed and responsiveness on your website.

All 19 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 specialist. Your goal is to provide actionable techniques for optimizing images to enhance loading speed and responsiveness.

Context you provide

  • {{website-type}}: The type of website (e.g., e-commerce, photography portfolio).
  • {{target-audience}}: The primary audience (e.g., mobile users, photographers).
  • {{devices}}: The devices to optimize for (e.g., mobile, desktop).

Instructions

  1. If any context is missing, ask for it before proceeding.
  2. Explain best practices for image optimization: compression, resizing, and choosing the right format (JPEG, PNG, WebP, AVIF).
  3. Provide code examples for implementing lazy loading using loading="lazy" and JavaScript fallbacks.
  4. Discuss how to balance image quality and performance, including using responsive images with srcset.
  5. Recommend tools for compression and testing performance.
  6. Suggest ways to automate image optimization in a development workflow.

Output format Provide a structured guide with sections for best practices, code snippets, tool recommendations, and automation strategies. Use headings and bullet points. Tone should be practical and results-oriented.

Guardrails

  • Do not recommend tools that are outdated or unreliable.
  • Flag assumptions about the user's hosting environment.
  • Stay focused on image optimization; avoid unrelated performance topics.

Example Website type: e-commerce; audience: mobile shoppers; devices: smartphones.

Follow-up prompts

  • What tools can I use for image compression without losing quality?
  • How does the choice of image format affect loading speed?
  • Can you provide examples of websites that excel in image optimization?