TLDR Dev · ARTICLES & TUTORIALS

LAZY FIELDS FOR 30X SPEEDUP WITHOUT DECORATORS OR TRANSFORMS

joist-orm.io8 min read

Summary from the TLDR Dev newsletter

The Joist TypeScript ORM achieved a 30x performance speedup by making class fields lazy without using decorators or transforms. It used `Object.create()` to skip constructor field initialization and moved relations to the prototype, allowing relations to only be created when actually accessed rather than eagerly initializing all relations for every instance. This approach reduced memory allocation costs, especially for entities with many relations (30+ in some cases).