Skip to content

Instantly share code, notes, and snippets.

@staydecent
Created December 3, 2018 16:48
Show Gist options
  • Save staydecent/9c43364c8f52e944fdb1100bcc4bae82 to your computer and use it in GitHub Desktop.
Save staydecent/9c43364c8f52e944fdb1100bcc4bae82 to your computer and use it in GitHub Desktop.
Why Preact over React?

Why Preact over React?

  • Preact filesize is much smaller than React. ~8kb vs ~100kb
  • Rendering performance is also faster. (https://developit.github.io/preact-perf/)
  • Preact, while it is a subset of React, implements the most common API surface of React. This means the exact same stateless functional components and ES6 class based component definitions will work with either library.
  • Preact also supports Contexts and Refs, which can be useful in more complex apps.
  • PropTypes, Hooks, and other features that are not included with the base Preact library are opt-in. Many of which are provided by the preact-compat library.
  • Full compatibility can be acheived for third-party libraries built for React by aliasing the preact-compat library to "react" and "react-dom".

This means you get a smaller, faster app with a simpler React API surface to learn. If complexity of your app eventually requires more advanced features, you can include preact-compat to acheive the full React API.

This allows your app the be downloaded, viewed, and interacted with, with greater speed than if you chose React.

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