Discover how tiny interactive islands can make your website lightning fast!
Why Islands architecture in Fresh in Deno? - Purpose & Use Cases
Imagine building a website where every small interactive part needs to reload the whole page or run heavy JavaScript everywhere, even on parts that don't change.
Manually adding JavaScript to every part makes the site slow, uses too much data, and is hard to keep working well on all devices.
Islands architecture in Fresh lets you add small interactive pieces only where needed, keeping the rest of the page simple and fast.
Load full JavaScript bundle for entire page
Handle all interactions globallyDefine small interactive islands
Load JavaScript only for those islandsThis approach makes websites faster, lighter, and easier to maintain by focusing JavaScript only where it matters.
Think of a news site where only the comment box is interactive, while the article text loads instantly without extra scripts.
Manual full-page JavaScript slows down websites.
Islands architecture loads scripts only for interactive parts.
Fresh uses this to build fast, modern web apps easily.
Practice
Solution
Step 1: Understand Islands architecture concept
Islands architecture divides a web page into static parts and small interactive components called islands.Step 2: Identify the main benefit
This split improves page speed and maintainability by only hydrating interactive parts.Final Answer:
To split pages into static and interactive parts for better performance -> Option AQuick Check:
Islands architecture = split static + interactive [OK]
- Thinking all page parts are interactive
- Believing Islands disables JavaScript
- Assuming full client-side rendering
Solution
Step 1: Recall correct tag casing
Fresh uses uppercaseISLANDtag to mark interactive components.Step 2: Check tag usage
TheISLANDtag wraps the component, so it needs opening and closing tags.Final Answer:
<ISLAND>MyComponent</ISLAND> -> Option AQuick Check:
Correct tag is uppercase ISLAND with open/close [OK]
- Using lowercase or mixed case tags
- Using self-closing without children
- Confusing with other component tags
export default function Page() {
return (
<main>
<h1>Welcome</h1>
<ISLAND><Counter /></ISLAND>
<p>Static text</p>
</main>
);
}Solution
Step 1: Identify ISLAND usage
TheCountercomponent is wrapped inside theISLANDtag, marking it interactive.Step 2: Understand static vs interactive parts
The heading and paragraph are outside ISLAND, so they remain static and non-interactive.Final Answer:
Only the Counter component inside the ISLAND tag is interactive -> Option CQuick Check:
ISLAND wraps interactive parts only [OK]
- Assuming whole page is interactive
- Thinking ISLAND tag is invalid
- Believing static parts become interactive
export default function Page() {
return (
<main>
<ISLAND><Button /></ISLAND>
<ISLAND><Button /></ISLAND>
</main>
);
}Solution
Step 1: Analyze multiple ISLAND usage
Using the same interactive component multiple times inside separate ISLAND tags can cause hydration conflicts if keys are missing.Step 2: Understand hydration uniqueness
Each island needs a unique key or identifier to avoid duplicate hydration errors.Final Answer:
Using multiple ISLAND tags with the same component can cause duplicate hydration issues -> Option BQuick Check:
Duplicate islands need unique keys to avoid errors [OK]
- Thinking ISLAND tags must be self-closing
- Believing components can't be inside ISLAND
- Assuming ISLAND wraps only HTML elements
Solution
Step 1: Understand hydration granularity
Wrapping each button in its ownISLANDallows independent hydration, improving performance by loading only needed parts.Step 2: Importance of unique keys
Assigning unique keys to each island prevents hydration conflicts and ensures smooth interactivity.Final Answer:
Wrap each button in its own <ISLAND> with unique keys to hydrate only needed parts -> Option DQuick Check:
Separate islands with keys = better performance [OK]
- Grouping all buttons in one island causing unnecessary hydration
- Not using ISLAND tags and hydrating whole page
- Misusing ISLAND on static content
Ready to prove it?
Pass the test and this pattern moves unknown
