Skip to content

Browsers Support

Principles

  • Use native and well supported features as much as possible
  • Use new syntaxes only if they are in an advanced stage of specification, transpile them automatically using build tools
  • Avoid APIs that are not supported by the browsers your project needs to support, we don’t want to ship polyfills

Compatibility

Syntax

Vite, our go-to bundler, use EsBuild under the hood and automatically transpiles the code to support a defined range of browsers by default for both CSS & JavaScript.

You can change the list of compatible browsers by customizing the build.target option.

APIs

Avoid APIs that are not fully supported in the first place. If you really need them, consider degrading the exeperience gracefully. As a last resort, include a dedicated polyfill through renowned sources like core-js.

Legacy

Older projects often use Babel with @babel/preset-env to transpile JavaScript and include API polyfills.

Projects that do not use Vite may use Browserslist to define the list of browsers we want to be compatible with and Autoprefixer to add CSS prefixes. They shouldn’t be necessary in a Vite/EsBuild setup.

Resources

  • CanIUse.com allows you to check browsers support for a given feature