Fine, I'll build my own text editor(dbushell.com)
257 points by Alephinitesimal 8 days ago | 251 comments
tl;dr: A developer experiments with building a browser-based text editor, first trying `<canvas>` rendering (fast but inaccessible and lacking free features like selection and scrolling), then `contenteditable` with `plaintext-only` (better accessibility but performance degrades with size), and finally settling on `<textarea>` with a separate syntax-highlighting layer for best performance. Along the way they hit gotchas like spellcheck causing input latency, CSS `::highlight` bottlenecks, and UTF-16 string quirks with emoji, concluding they've got 90% of an editor with 1% of the features.
HN Discussion:
  • ~Using textarea was the obvious right choice; author should have gone further and ditched the browser entirely
  • Text editors are beautiful, satisfying pieces of engineering to watch being built
  • The author retraced a well-known path that others (like CodeMirror) already walked years ago
  • Building your own editor is unnecessary when tools like Emacs or existing libraries already solve this
  • The mainstream dismissal of performance optimization is wrong; efficiency matters long-term