Paul Krill
Editor at Large

Slim, speedy Svelte framework puts JavaScript on a diet

news
Dec 2, 20162 mins

The framework removes abstractions in order to produce vanilla JavaScript that runs much faster, particularly on mobile devices

cheetah run speed fast quick predator animal wildlife
Credit: TNS Sofres

While there’s already a plethora of JavaScript frameworks available, there always seems to be room for another trying to provide something new. Enter the Svelte framework, which focuses on building apps for speed by converting them into pure vanilla JavaScript.

Svelte, available in a 1.0.0 release, turns templates into framework-less JavaScript. Developers write components using HTML, CSS, and JavaScript; the Svelte build process compiles them into standalone JavaScript modules.

“By statically analyzing the component template, we can make sure that the browser does as little work as possible,” said Rich Harris, Svelte founder and interactive editor at The Guardian. Svelte applications run faster than those from other JavaScript frameworks, including React, Vue, Angular, and Ember.

Frameworks like React solved the productivity problem of how to build rich, complex applications without creating a “pile of unmaintainable spaghetti code,” said Harris. And the front end community abandoned old ideas about separation of concerns and embraced a component-driven mindset. But this has come at a cost to users.

“Existing frameworks tend to be large enough that your application becomes slow to start up on mobile phones, especially on Android, which is where the bulk of market growth is happening.” Browsers have had to spend time parsing and evaluating JavaScript, during which time a phone is unresponsive, then there’s a performance cost to framework abstractions. “Svelte solves these problems by removing those abstractions. The hard work happens at compile time rather than run time — it spits out highly optimized low-level DOM manipulation code specific to your application.”

Svelte’s compiler detects which features a component uses by analyzing source code. “If a feature isn’t being used, Svelte doesn’t include the code for it,” said Harris. “You end up with exactly what you need.” The framework also offers advantages in code-splitting and supports capabilities like SVG and encapsulated CSS.

There still is plenty of work left to do on Svelte, Harris cautioned. It must be fitted with capabilities like server-side rendering and be integrated with existing tools, and he wants to add features like declarative translations.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author