Ship ZERO JavaScript by default.
Add JavaScript ONLY where you need it.
Static content is HTML that's generated at BUILD TIME and doesn't change after the page is sent to the browser.
💡 Refresh the page - the timestamp stays the same! It was generated once during build and "frozen" into the HTML.
Dynamic content is content that changes or updates in the browser after the page loads, using JavaScript.
💡 This updates every second! It's calculated in your browser using JavaScript, not during the build.
Ship ZERO JavaScript by default.
Add JavaScript ONLY where you need it.
Everything is JavaScript
✅ Very interactive
❌ Heavy bundle size
❌ Slower initial load
❌ Runs even for static content
Static HTML by default
✅ Lightning fast
✅ Zero JavaScript for static parts
✅ Add interactivity only where needed
✅ Best of both worlds
The magic of Astro is you can have STATIC content with DYNAMIC enhancements. This is perfect for creative development!
Result: Fast load + Interactive features
Result: SEO-friendly + Stunning animations
Result: Instant load + Functional forms
GSAP runs at RUNTIME (in the browser), not at build time.
---
// BUILD TIME: Fetch project data
const project = {
title: "Cool Project",
description: "An amazing site"
};
---
<!-- STATIC: HTML structure generated at build -->
<div class="project" id="project-1">
<h3>{project.title}</h3>
<p>{project.description}</p>
</div>
<!-- DYNAMIC: GSAP animation runs in browser -->
<script>
import gsap from 'gsap';
// This runs when the page loads in the browser
gsap.from('#project-1', {
opacity: 0,
y: 50,
duration: 1
});
</script>
✅ Your HTML loads instantly (static)
✅ GSAP then animates it (dynamic)
✅ Best performance + Beautiful animations
When: You run npm run build
Where: Your computer / CI server
Static files in dist/ folder
When: User visits your site
Where: User's browser
Fast load + Interactive features
Frontmatter: Runs at build time (once)
<script>: Runs in browser (every visit)
Astro generates static HTML
No JavaScript unless you add it
Use <script> tags for interactivity
GSAP goes in <script> tags
Fast static content
+ Beautiful animations
= Perfect for creative dev! 🎯
This text was rendered at build time.
It can't change without rebuilding the site.
Click count: 0
This counter uses JavaScript to update dynamically.