Need advice about which tool to choose?Ask the StackShare community!

Mithril

88
79
+ 1
86
Svelte

1.6K
1.6K
+ 1
502
Add tool

Mithril vs Svelte: What are the differences?

Introduction: Mithril and Svelte are two popular JavaScript frameworks that are used to build user interfaces for web applications. While both frameworks share the goal of making web development more efficient and streamlined, there are several key differences between them.

  1. Virtual DOM vs Compiler approach: Mithril, like other popular frameworks such as React, uses a virtual DOM to efficiently update the UI. It compares the previous and current states of the virtual DOM and applies only the necessary updates. On the other hand, Svelte takes a different approach by compiling the components at build time. This means that Svelte doesn't rely on the virtual DOM and generates code that is optimized to run directly on the browser, resulting in a smaller bundle size and faster rendering.

  2. Size: Mithril is known for its small size, weighing in at just a few kilobytes. It has a minimalistic design and offers only the essential features needed to build web applications. Svelte, although it offers more features and capabilities, tends to have a larger bundle size due to its compiler-based approach. However, Svelte's ability to eliminate runtime dependencies can still result in smaller overall bundle sizes in certain cases.

  3. Reactivity: Both Mithril and Svelte provide reactive programming capabilities, allowing developers to efficiently update the user interface based on changes in the underlying data. However, Svelte takes this a step further with its reactive declarations and reactive statements. These features automatically update the UI whenever the referenced data changes, providing a more intuitive and declarative approach to handling reactivity.

  4. Component Structure: Mithril organizes components using a hierarchical structure, where components can have child components that inherit properties and state from their parent. Svelte, on the other hand, uses a flat component structure, where all components are independent and can be easily reused or composed together. This provides more flexibility in managing and organizing components in complex applications.

  5. Syntax and Templating: Mithril uses a JavaScript-based syntax for creating components and templates, allowing developers to use the full power of JavaScript to define and manipulate UI components. Svelte, on the other hand, uses a custom templating language that resembles HTML, with added features like reactive statements and expressions. This can make it easier for developers who are more familiar with HTML to quickly get started with Svelte.

  6. Build Process: Mithril can be used within any build process or framework, and it doesn't have any specific build requirements. Developers can choose their preferred build tools and configure them accordingly. Svelte, however, has its own build process based on Rollup, a module bundler. It provides a streamlined build experience with features like automatic code splitting and dead code elimination, but it can be a bit more restrictive for developers who prefer more flexibility in their build setup.

In summary, Mithril and Svelte have distinct approaches to building web applications. Mithril utilizes a virtual DOM, has a small footprint, supports hierarchical component structure, uses JavaScript syntax for templating, and can be easily integrated into any build process. On the other hand, Svelte uses a compiler approach, offers advanced reactivity features, has a different component structure with flat organization, uses its own templating language resembling HTML, and comes with its own build process based on Rollup.

Decisions about Mithril and Svelte
Máté Homolya
Senior developer at Self-employed · | 11 upvotes · 297.9K views
Migrated
from
ReactReact
to
SvelteSvelte

Svelte is everything a developer could ever want for flexible, scalable frontend development. I feel like React has reached a maturity level where there needs to be new syntactic sugar added (I'm looking at you, hooks!). I love how Svelte sets out to rebuild a new language to write interfaces in from the ground up.

See more
Alex Guesnon
Full-stack software engineer · | 3 upvotes · 119.5K views
Chose
SvelteSvelte
over
Vue.jsVue.js

Svelte 3 is exacly what I'm looking for that Vue is not made for.

It has a iterable dom just like angular but very low overhead.

This is going to be used with the application.

for old/ lite devices . ie. * android tv, * micro linux, * possibly text based web browser for ascci and/or linux framebuffer * android go devices * android One devices

See more
Manage your open source components, licenses, and vulnerabilities
Learn More
Pros of Mithril
Pros of Svelte
  • 16
    Lightweight
  • 12
    Faster than React
  • 10
    Pure JavaScript
  • 10
    Virtual Dom
  • 8
    Robust
  • 7
    Unopinionated
  • 7
    Works with ES6
  • 6
    Very active development
  • 5
    Intelligent auto-redrawing system
  • 3
    Flux compatible
  • 2
    Small Learning Curve
  • 59
    Performance
  • 41
    Reactivity
  • 36
    Components
  • 35
    Simplicity
  • 34
    Javascript compiler (do that browsers don't have to)
  • 30
    Lightweight
  • 28
    Near to no learning curve
  • 26
    Real Reactivity
  • 26
    Fast as vanilajs
  • 22
    All in one
  • 18
    Compiler based
  • 18
    Use existing js libraries
  • 17
    SSR
  • 16
    Scalable
  • 16
    Very easy for beginners
  • 13
    Composable
  • 12
    No runtime overhead
  • 12
    Ease of use
  • 10
    Built in store
  • 9
    Typescript
  • 7
    Start with pure html + css
  • 7
    Best Developer Experience
  • 6
    Templates
  • 4
    Speed

Sign up to add or upvote prosMake informed product decisions

Cons of Mithril
Cons of Svelte
  • 1
    Virtual Dom
  • 3
    Event Listener Overload
  • 2
    Little to no libraries
  • 2
    Complex
  • 2
    Learning Curve
  • 2
    Hard to learn

Sign up to add or upvote consMake informed product decisions

- No public GitHub repository available -

What is Mithril?

Mithril is around 12kb gzipped thanks to its small, focused, API. It provides a templating engine with a virtual DOM diff implementation for performant rendering, utilities for high-level modelling via functional composition, as well as support for routing and componentization.

What is Svelte?

If you've ever built a JavaScript application, the chances are you've encountered – or at least heard of – frameworks like React, Angular, Vue and Ractive. Like Svelte, these tools all share a goal of making it easy to build slick interactive user interfaces. Rather than interpreting your application code at run time, your app is converted into ideal JavaScript at build time. That means you don't pay the performance cost of the framework's abstractions, or incur a penalty when your app first loads.

Need advice about which tool to choose?Ask the StackShare community!

Jobs that mention Mithril and Svelte as a desired skillset
What companies use Mithril?
What companies use Svelte?
Manage your open source components, licenses, and vulnerabilities
Learn More

Sign up to get full access to all the companiesMake informed product decisions

What tools integrate with Mithril?
What tools integrate with Svelte?

Sign up to get full access to all the tool integrationsMake informed product decisions

Blog Posts

JavaScriptGitHubReact+12
5
4208
What are some alternatives to Mithril and Svelte?
React
Lots of people use React as the V in MVC. Since React makes no assumptions about the rest of your technology stack, it's easy to try it out on a small feature in an existing project.
JavaScript
JavaScript is most known as the scripting language for Web pages, but used in many non-browser environments as well such as node.js or Apache CouchDB. It is a prototype-based, multi-paradigm scripting language that is dynamic,and supports object-oriented, imperative, and functional programming styles.
Python
Python is a general purpose programming language created by Guido Van Rossum. Python is most praised for its elegant syntax and readable code, if you are just beginning your programming career python suits you best.
Node.js
Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
HTML5
HTML5 is a core technology markup language of the Internet used for structuring and presenting content for the World Wide Web. As of October 2014 this is the final and complete fifth revision of the HTML standard of the World Wide Web Consortium (W3C). The previous version, HTML 4, was standardised in 1997.
See all alternatives