0
0
Astroframework~20 mins

client:visible for viewport-based loading in Astro - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Astro Viewport Loading Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What happens when using client:visible in Astro?
Consider an Astro component with client:visible directive. What is the behavior of this component in the browser?
Astro
<MyComponent client:visible />
AThe component loads and runs its client-side JavaScript only when it enters the viewport.
BThe component loads and runs its client-side JavaScript immediately on page load.
CThe component never loads its client-side JavaScript, only static HTML is rendered.
DThe component loads client-side JavaScript after a fixed delay regardless of viewport.
Attempts:
2 left
💡 Hint
Think about when the browser detects the component is visible on screen.
📝 Syntax
intermediate
1:30remaining
Which is the correct syntax to use client:visible in Astro?
You want to load a component only when it becomes visible in the viewport. Which of the following is the correct way to write this in Astro?
A<MyComponent client:visible />
B<MyComponent client:visible={true} />
C<MyComponent client:visible='true' />
D<MyComponent clientVisible />
Attempts:
2 left
💡 Hint
Astro directives use colon syntax without values for boolean flags.
🔧 Debug
advanced
2:00remaining
Why does client:visible not trigger loading when component is already visible on page load?
You added client:visible to a component that is visible immediately on page load, but its client-side JavaScript does not run. What is the most likely cause?
Astro
<MyComponent client:visible />
AThe <code>client:visible</code> directive only works after scrolling, not on initial viewport.
BThe component is inside a container with CSS <code>display: none</code> or <code>visibility: hidden</code> on load.
CAstro does not support <code>client:visible</code> for components above the fold.
DThe component must have an explicit <code>id</code> attribute for <code>client:visible</code> to work.
Attempts:
2 left
💡 Hint
Check if CSS hides the component initially.
state_output
advanced
2:00remaining
What is the state of a client:visible component before it enters the viewport?
Before a component with client:visible loads its client-side JavaScript, what is rendered and what state does it have?
Astro
<MyComponent client:visible />
AThe component is fully interactive but hidden with CSS until visible.
BThe component runs client-side JavaScript but does not render anything until visible.
COnly the static HTML from the server is rendered; no client-side interactivity or state is active.
DThe component is replaced with a loading spinner until it becomes visible.
Attempts:
2 left
💡 Hint
Think about what the browser receives before JavaScript loads.
🧠 Conceptual
expert
2:30remaining
Why choose client:visible over client:load in Astro?
Which of the following best explains the advantage of using client:visible instead of client:load for loading components?
A<code>client:visible</code> disables client-side JavaScript entirely, making the component static.
B<code>client:visible</code> loads the component immediately but delays rendering until visible, improving SEO.
C<code>client:visible</code> preloads the component's JavaScript before page load to avoid delays when scrolling.
D<code>client:visible</code> delays JavaScript loading until the component is actually seen, improving initial page load performance and reducing unused code execution.
Attempts:
2 left
💡 Hint
Consider when the JavaScript actually downloads and runs.