Skip to content

251. Use Catalyst for client-side behaviours

Date: 2022-04-12

Status

Accepted

Context

Existing Primer ViewComponents behaviours don't use Catalyst or any other dependency, while GitHub developers often start writing a component using Catalyst.

Removing the Catalyst dependency from the Web Component is an extra burden on Web Developers with few benefits. The library is ~1kb of JavaScript, and github.com already includes the library as part of its client-side bundle. Adding the library to Primer ViewComponents does not affect github.com and has a minimal effect on other applications using Primer ViewComponents.

Decision

Any new Primer ViewComponent behaviours should be authored using Catalyst.

Considered Options

  • Don't use Catalyst in PVC.
    • Pros: Developers who don't have Catalyst experience don't need to learn how the library works.
      • The bundle size doesn't need to increase by 1kb.
    • Cons:
      • Migrating components from the github.com codebase would need to be converted to Web Components without Catalyst.
  • Use another JavaScript behaviour library or strategy than Catalyst.
    • Pros:
      • The bundle size doesn't need to increase by 1kb.
    • Cons:
      • Migrating components from the github.com codebase would need to be converted to Web Components without Catalyst.
      • PVC JavaScript behaviours would differ from how GitHub engineers write JavaScript behaviours today.

Consequences

  • The Primer ViewComponents JS bundle gets larger.
  • Developers unfamiliar with Catalyst need to get familiar with the library.