Skip to content

Instantly share code, notes, and snippets.

@CLLane
Last active November 3, 2019 21:40
Show Gist options
  • Save CLLane/f660f2b5383f9eb57050b865d8cd670b to your computer and use it in GitHub Desktop.
Save CLLane/f660f2b5383f9eb57050b865d8cd670b to your computer and use it in GitHub Desktop.

Svelte is a ligh weight JavaScript library, much like other user interface frameworks you might have heard of like React.js and Vue.js. Developed by Rich Harris Svelte is meant to be a "Framework without the framework." Designed to improve run times this framework is a lightweight option for JS code it imporves loading/run time while compiling your code into vanilla JS. The hope for this open source framework is that a developer would use less code, save memory, improve compile time all while still having access to state management, custom component events, and simple/familiar code. The cons of Svelte center around the fact that it is relatively new and therefore has a small, yet devoted, community.

Svelte is very similar to React the biggest differnce is that Svelte does not operate of the virtual DOM. Then second biggest way that Svelte differentiates itself from React is there is no this.state in fact there is no specific syntax for state managment in Svelte any variable is available via just a simple let statement, and when these variables change it automatically cues a re-render. Event handling in React and Svelte are very similar, the only difference being that Svelte use 'on:Event' syntax while React uses 'onClick'.

Svelte is a new framework, just three years old, but it is worth watching and getting some experience with, not only does it run faster and handle heavy traffic better than React it is a very straight forward language to learn. It at its core is a compiler acting like a framework during the build process which results in a small components that do no more or less than you program them to do. Over all the jump from React or Vue to Svelte does not seem daunting, and the performance benifits sound unbelievable. The decision to migrate to Svelte for your next project shouldn't be scary, their is a tutorial at svelte.dev, and being halfway through it myself I can honestly say that it is a piece of cake.

Resources
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment