0
0
Remixframework~20 mins

Image optimization in Remix - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Remix Image Optimization Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What is the output of this Remix image component?
Consider this Remix component using the <img> tag with the loading attribute set to lazy. What behavior will the image exhibit in modern browsers?
Remix
export default function ProfilePic() {
  return <img src="/profile.jpg" alt="Profile picture" loading="lazy" width={200} height={200} />;
}
AThe image loads immediately when the page loads, ignoring lazy loading.
BThe image loads only when it is about to enter the viewport, saving bandwidth initially.
CThe image never loads because lazy loading disables it.
DThe image loads only after all other page content has loaded.
Attempts:
2 left
💡 Hint
Think about what lazy loading means for images in browsers.
📝 Syntax
intermediate
2:00remaining
Which Remix image import syntax is correct for automatic optimization?
Remix supports importing images for automatic optimization. Which import and usage syntax is valid?
A
import profilePic from '~/images/profile.jpg';

export default function() {
  return &lt;img src={profilePic} alt="Profile" /&gt;;
}
B
import { Image } from 'remix';

export default function() {
  return &lt;Image src="/images/profile.jpg" alt="Profile" /&gt;;
}
C
import profilePic from '~/images/profile.jpg';

export default function() {
  return &lt;Image src={profilePic} alt="Profile" /&gt;;
}
D
const profilePic = require('~/images/profile.jpg');

export default function() {
  return &lt;img src={profilePic} alt="Profile" /&gt;;
}
Attempts:
2 left
💡 Hint
Remix uses ES module imports and provides an Image component for optimization.
🔧 Debug
advanced
2:00remaining
Why does this Remix image optimization fail to resize?
This Remix component tries to resize an image using the Image component with width and height props, but the image always loads full size. What is the cause?
Remix
import { Image } from '@remix-run/react';

export default function Banner() {
  return <Image src="/banner.jpg" alt="Banner" width={300} height={100} />;
}
AThe <code>Image</code> component does not support width and height props for resizing.
BThe width and height props must be strings, not numbers.
CThe <code>Image</code> component requires a <code>loader</code> prop to resize images.
DThe image path must be imported as a module for optimization to work.
Attempts:
2 left
💡 Hint
Think about how Remix optimizes images imported as modules.
state_output
advanced
2:00remaining
What is the rendered output of this Remix image with srcSet?
Given this component, what is the srcset attribute value in the rendered <img> tag?
Remix
import { Image } from '@remix-run/react';
import logo from '~/assets/logo.png';

export default function Logo() {
  return <Image src={logo} alt="Logo" widths={[100, 200, 400]} />;
}
A"/assets/logo-100.png 100w, /assets/logo-200.png 200w, /assets/logo-400.png 400w"
B"/assets/logo.png 100w, /assets/logo.png 200w, /assets/logo.png 400w"
C"/assets/logo.png"
DNo <code>srcset</code> attribute is rendered.
Attempts:
2 left
💡 Hint
Remix generates multiple image sizes for responsive loading.
🧠 Conceptual
expert
3:00remaining
Why is using Remix's Image component better than a plain for optimization?
Select the best explanation for why Remix's Image component improves image loading compared to a standard <img> tag.
AIt automatically generates multiple image sizes and formats, serving the best one for the device and browser, improving performance and bandwidth.
BIt forces all images to load at the largest size to ensure quality on all devices.
CIt disables lazy loading to make images appear instantly on page load.
DIt converts all images to SVG format for better scalability.
Attempts:
2 left
💡 Hint
Think about responsive images and modern formats.