Svelte 3: The Framework that Disappears
It’s 2019, and framework fatigue is real. We’re all tired of shipping 100KB of runtime code just to show a "Hello World." Rich Harris and the Svelte team have just released Svelte 3, and it’s a radical departure from React and Vue.
Svelte isn't a library you call; it’s a compiler that runs during your build step.
Truly Reactive State
In Svelte 3, reactivity is as simple as an assignment. No setState, no this.data. The compiler "instruments" your code to know exactly when a variable changes.
<script>
let count = 0;
function handleClick() {
// This assignment triggers a DOM update!
count += 1;
}
// Reactive declarations (like spreadsheets!)
$: doubled = count * 2;
</script>
<button on:click={handleClick}>
Clicked {count} {count === 1 ? 'time' : 'times'}
</button>
<p>Double is {doubled}</p>
No Virtual DOM
Svelte doesn't use a Virtual DOM to diff changes at runtime. Instead, the compiler generates surgical DOM updates (like element.textContent = ...) that run only when the specific variable changes. This means your app is faster and your bundles are tiny.
CSS Scoping by Default
Svelte automatically scopes your CSS to the component, so you don't have to worry about class name collisions.
<style>
p {
color: purple;
font-family: 'Comic Sans MS', cursive;
font-size: 2em;
}
</style>
<p>I am scoped!</p>
In 2019, Svelte is proving that the best framework is the one that isn't there when your code actually runs. It’s moving the "heavy lifting" from the user's browser to your build server.
Aunimeda develops websites and web applications for businesses - corporate sites, e-commerce, portals, and custom platforms.
Contact us to discuss your web project. See also: Web Development, E-commerce Development