0
0
Astroframework~20 mins

Font optimization in Astro - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Astro Font Optimization Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
How does Astro optimize font loading by default?

Astro automatically optimizes font loading to improve page speed. What is the default behavior of Astro regarding font optimization?

AAstro preloads fonts using <link rel="preload"> tags and uses font-display: swap.
BAstro disables font optimization by default and requires manual setup.
CAstro inlines all font files as base64 in the HTML to avoid extra requests.
DAstro converts fonts to SVG format for faster rendering.
Attempts:
2 left
💡 Hint

Think about how browsers prioritize font loading to avoid invisible text.

📝 Syntax
intermediate
2:00remaining
Which Astro config snippet correctly enables Google Fonts optimization?

Astro supports automatic Google Fonts optimization. Which config snippet correctly enables this feature?

A
export default {
  googleFonts: {
    enabled: true
  }
}
B
import { googleFonts } from '@astrojs/google-fonts';

export default {
  integrations: [
    googleFonts({ optimize: true })
  ]
}
C
export default {
  integrations: [
    googleFonts({ optimize: true })
  ]
}
D
export default {
  integrations: [
    GoogleFonts({ optimizeFonts: true })
  ]
}
Attempts:
2 left
💡 Hint

Look for correct capitalization and property names in the integration.

🔧 Debug
advanced
2:00remaining
Why does font optimization fail when using a custom font URL in Astro?

Consider this Astro component snippet that tries to optimize a custom font:

<link rel="stylesheet" href="https://example.com/fonts/custom-font.css" />

Font optimization does not work as expected. What is the most likely cause?

AAstro only optimizes fonts from Google Fonts by default, not custom URLs.
BThe custom font URL must use HTTPS for optimization to work.
CThe font CSS file must include <code>@font-face</code> rules with local sources.
DAstro requires the font files to be imported directly in the component for optimization.
Attempts:
2 left
💡 Hint

Think about which font sources Astro can optimize automatically.

🧠 Conceptual
advanced
2:00remaining
What is the impact of using font-display: optional in Astro font optimization?

Astro allows configuring font-display behavior during font optimization. What happens if you set font-display: optional?

AThe font is downloaded only if the user is on a fast network connection.
BThe browser blocks rendering until the font is fully loaded, causing a delay.
CThe font is always downloaded but never displayed to improve performance.
DThe browser will use the fallback font immediately and may never swap to the custom font if slow.
Attempts:
2 left
💡 Hint

Consider how font-display: optional affects font swapping and fallback usage.

state_output
expert
3:00remaining
What is the rendered output when using Astro's font optimization with preload disabled?

Given this Astro component snippet:

<style>
  @import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');
</style>

<h1 class="font-roboto">Hello</h1>

If font optimization is enabled but preload is explicitly disabled, what will the browser behavior be?

AThe font CSS is preloaded but the font files are not downloaded, causing invisible text.
BThe font is inlined in the HTML, so no network requests occur for fonts.
CThe font CSS is loaded normally without preload; text may show fallback font briefly before swapping.
DThe font is blocked from loading, so only fallback fonts are used permanently.
Attempts:
2 left
💡 Hint

Think about what disabling preload means for font loading sequence.