Skip to content

Yes but does it scale? #2546

Closed as not planned
Closed as not planned
@Rich-Harris

Description

@Rich-Harris

Another blog post that really needs to be on the site. Switched-on developers frequently say 'I get that the imperative update code is faster than VDOM diffing or whatever, and I understand that there's no need for a big runtime, but surely the incremental cost of a component is significantly larger? Doesn't that mean Svelte hits an inflection point where the bundle size is larger than if we'd just used a traditional framework?'

It's a good question that deserves a good answer. The bullet point version is this:

  • Theoretically, yes there is an inflection point. Where that inflection point is is the only thing that really matters. In practice, you're unlikely to hit that inflection point on any given page of your app, as long as you're using code-splitting (which Sapper gives you OOTB)
  • The incremental cost of Svelte components isn't that high. The code is designed to be readable, but also to minify really well, and it makes use of a shared internal library
  • The initial bundle size is the one that really matters. If subsequent bundles are slightly chunkier than they need to be, it's not the end of the world — because by that point we have service workers and preloading and so on
  • The beauty of the compiler-centric approach is that we can vary the target output. An example is generating string-concat code for SSR. If it ever became a real problem, we could investigate approaches like Glimmer's, where we generate bytecode instead of raw JS. We could even have different approaches within a single app — imperative JS for a fast initial load, then load the VM and use bytecode for subsequent navigations
  • Bundle size is only one facet of the Svelte experience

Of course, the best way to show this is with demo apps, such as updating the RealWorld app.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions