Performance: Public directory for static assets
This affects page load speed by controlling how static files like images, fonts, and scripts are served directly without extra processing.
<script src="/analytics.js" defer></script> // Placing analytics.js in the public directory and referencing it directly
import '../assets/analytics.js'; // Importing JS files bundles them into the app's JavaScript bundle
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Importing assets in JS bundle | Low | 0 | High (due to delayed load) | [X] Bad |
| Serving assets from public directory | Low | 0 | Low (loads early) | [OK] Good |
public directory in an Astro project?logo.png stored in the public directory inside an Astro component?/logo.png correctly points to the file in the public folder.icon.svg inside the public/icons folder, what will be the URL to access it in the browser?public/icons is accessed as /icons/icon.svg.custom-font.woff2 inside the public/fonts folder but your CSS @font-face rule is not loading it. Which of the following is the most likely cause?url('fonts/custom-font.woff2') is relative and incorrect; it should be url('/fonts/custom-font.woff2').guide.pdf to your Astro site. You placed it inside the public/docs folder. How should you create a link in your component so users can download it when clicked?/docs/guide.pdf as href and include the download attribute for direct download.Pass the test and this pattern moves unknown