client:visible in Astro?client:visible directive. What is the behavior of this component in the browser?<MyComponent client:visible />
The client:visible directive in Astro delays loading the client-side JavaScript until the component scrolls into the viewport. This improves performance by avoiding unnecessary script execution.
client:visible in Astro?Astro uses directives like client:visible as boolean flags without assigning values. Adding =true or quotes is invalid syntax.
client:visible not trigger loading when component is already visible on page load?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?<MyComponent client:visible />
If the component or its parent container is hidden with CSS on page load, the browser does not detect it as visible, so client:visible does not trigger loading.
client:visible component before it enters the viewport?client:visible loads its client-side JavaScript, what is rendered and what state does it have?<MyComponent client:visible />
With client:visible, Astro sends static HTML initially. The client-side code and interactivity only load when the component scrolls into view.
client:visible over client:load in Astro?client:visible instead of client:load for loading components?client:visible improves performance by loading JavaScript only when needed, unlike client:load which loads immediately on page load regardless of visibility.