Where a JavaScript spreadsheet begins
A JavaScript spreadsheet begins with its goals, set before the first cell is drawn. Priena’s goals are four: a grid that developers embed in any application, the interface people already know from Excel and Google Sheets, a million rows and more painted on a canvas, and any language, direction, and color scheme. Each goal became a part of the code that everything else stands on. This essay describes those parts as they are built today, the measurements behind them, and what each one costs.
Harvard, 1978
In the spring of 1978, Dan Bricklin was an MBA student at Harvard Business School, working case studies on paper with a calculator. He wanted a calculator on the desk that he could “punch in a few numbers, circle them to get a sum, do some calculations, and answer ‘10% will be fine!’” With Bob Frankston, he wrote VisiCalc, which came out on the Apple II in 1979. In Bricklin’s words, the tool had to be worth using the first time you needed an answer, “in a way that would let you benefit the next time by just changing a few values and recalculating.”
A spreadsheet still does this almost fifty years later: a person changes a value, and everything that depends on it changes too. Over those years people learned how a spreadsheet behaves: which key moves where, what a paste does to a selection, what Ctrl+Z takes back. A spreadsheet built today meets those expectations or makes its users learn new ones.
The goals
Before writing code, we described Priena in one sentence. It is a spreadsheet grid that developers embed in their own applications, whatever those are built with, with the Excel and Google Sheets interface people already know, on a renderer that stays fast at a million rows and more.
Why would anyone need a million rows in a browser? Most users do not. In our experience, people far more often ask to work comfortably with tables of 50,000 to 100,000 rows. That is already a large volume for many internal tools, imports, catalogs, and data-heavy applications, and at that size some grids slow down noticeably. A million rows is the margin above that. Row count is only one factor in speed; the number of columns, custom rendering, editing, the browser, and the machine matter too.
Real data also varies. We know a team that works with CSV files for data science research. Their files usually hold 50,000 to 100,000 rows, but sometimes a file of 700,000 or 800,000 comes along. The user could split such a file into parts, but a modern browser can hold it whole if the grid is built for it. We set the goal that a rare large file opens in the same grid as the others.
Each part of the sentence became a requirement. “Embed in their own applications” means the grid is a guest on someone else’s page and cannot take over its styles, its focus, or its framework. “The interface people already know” means we follow spreadsheet conventions by default and depart from them only with a reason. “A million rows and more” means the cost of a frame must depend on the screen, not on the data. Our rule for the code says so: “Work per frame scales with the viewport, never with the dataset.”
The interface comes from Excel and Google Sheets
A user who opens a grid inside a business application already has years of habits: arrow keys, Shift to extend, Ctrl+C and Ctrl+V, a double click to edit, Delete to clear, a small square in the corner to drag a pattern down.
Jakob Nielsen’s fourth usability heuristic, published in 1994, is “Consistency and standards”: “Users should not have to wonder whether different words, situations, or actions mean the same thing. Follow platform and industry conventions.” Nielsen Norman Group explains why with Jakob’s law: “people spend most of their time using digital products other than yours.” For many people who work in spreadsheets, those other products are Excel and Google Sheets.
The heuristic does not say that every difference from Excel is a mistake. It says that departing from a strong convention costs the user something: they can no longer rely on what they learned. So Priena follows these conventions by default, and a departure needs a written reason. For every feature, we check by hand how Excel and Google Sheets behave and write it down before we build it.
This reaches details users rarely notice. A paste follows Excel’s target rules. A single cell takes the whole block from itself. A range that is a whole multiple of the block is filled. Any other range takes the block once from its top-left corner. Copied text is written as Excel writes it, tab-separated with Windows line endings, so a copy from Priena pastes cleanly into Excel and back. The dashed outline around a copied range has an L at each corner, as in Google Sheets.
The cost of this goal is that we invent no interactions of our own. A demo of Priena looks like Excel.
A core without a framework
A developer who embeds a grid has already chosen a framework: React, Vue, Angular, Svelte, or none. If a grid’s core depends on one framework, it inherits that framework’s assumptions, and every other framework needs an adapter around them or a second implementation. So Priena’s core is plain TypeScript, with no framework code and no runtime dependencies. A test in the repository fails if the published package lists a single dependency.
A framework gives a component its lifecycle, its state, and its rendering. Without one, the core provides all three, and a wrapper for a framework only translates. The wrapper maps its framework’s props onto the grid’s options one to one, and its lifecycle onto three calls: createGrid, setOptions, and destroy. It holds no logic of its own; when a wrapper needs a capability, the core gets it. The React wrapper is 123 lines of code.
For a wrapper to stay this thin, the core behaves the way frameworks expect. Passing an equal value again does nothing. Any option can change at any time. New options never reset what the user did, such as a sort or a column width. Destroying the grid and mounting it again on the same element works, because React’s development mode does exactly that.
The cost is that everything the user sees in the DOM is ours to write: menus, windows, tooltips, text inputs, and buttons.
A UI kit of our own
Besides cells, a spreadsheet has ordinary interface parts: a cell editor, a context menu, sheet tabs, a window to resize a column, a confirmation before a delete, notifications. All of them are built on one private package, our UI kit, which ships inside the grid.
We looked at existing libraries first. Floating UI does the placement math well, but it would be a runtime dependency, and our core has none. None of the libraries we evaluated met all three of our requirements: framework independence, no runtime dependencies, and popups that work when the grid sits inside another modal window. The third requirement rules out a lot. A popup placed at the end of the page’s body lands outside a client’s modal. The modal’s focus trap then pulls focus away from the popup, or the page behind the modal is inert and nothing in the popup can be pressed.
So the kit is plain TypeScript, on top of what browsers now do themselves. A menu or a tooltip is a popover in manual mode, drawn in the browser’s top layer, where no clipping, transform, or z-index on the page can hide it. It stays a descendant of the grid’s element, so it keeps the grid’s theme and font and stays inside a client’s modal. A window is the browser’s own <dialog>, opened with showModal(). The browser provides the backdrop, the inert page behind it, Escape, and focus returning on close; the kit adds no focus trap and no z-index of its own. Icons are stored as stroked paths on a 16-by-16 grid, so the same icon draws in a menu and on the canvas.
The kit holds 11 components and about 2,300 lines of TypeScript. The Popover API needs Chrome 114, Firefox 125, or Safari 17, and Priena has no fallback for older browsers.
Language, direction, and colors
Right-to-left text and themes are easy to postpone. Right to left is not the most common case worldwide, but for a local company in the Middle East a correct right-to-left interface is a basic requirement.
Setting direction: rtl once is not the hard part. In a large interface, the direction ends up built into many places: a layout that uses left and right, an icon that points one way, keyboard behavior and popup placement that assume left to right. Each can be fixed later, but together they are a migration through the whole system. Colors behave the same way. Hundreds of #fff and slightly different grays written by hand have to be sorted into tokens before a theme can change them, and the interface has to survive the change.
So these three are built into the base of the code.
Language. No word appears in the DOM or on the canvas unless it comes from a translation file. English is the source language, and Arabic is the test. Arabic is written right to left and has six plural forms where English has two, so it checks direction, letter shaping, plural rules, and layout at once. English checks almost none of that. Priena has 112 messages, each in both languages.
Direction. Every side in our CSS is a logical property, such as the inline start instead of the left, so the layout needs no separate rules for Arabic or Hebrew. The popups compute their positions in the same logical terms, and the canvas lays out its columns from the inline start.
Colors. A client changes the color of the whole grid, the cells and the menus alike, with one variable for its brand color, changes the grays with another, and turns the grid dark with CSS’s own color-scheme. There are eight public variables in all. Every other color is derived from them by mixing in the oklch color space, which keeps the lightness steps even for any hue.
Canvas or DOM
The usual way to draw a table on the web is to build it from elements, one per row and one per cell. The major JavaScript grids draw their cells this way. A million rows of elements cannot fit in a page, because each element costs memory, style, and layout, so these grids render only what fits on the screen. AG Grid’s documentation says that “the grid only renders what you see on the screen,” with a buffer of 10 rows above and below and “a maximum of 500 rows.” Handsontable’s documentation says its virtualization “draws only the visible part of the grid.” Both create and reuse elements as the user scrolls.
Priena paints its cells on one canvas instead. We expected the canvas to be faster, and measured it. We built a simple DOM grid of under 200 lines that renders only the visible cells and 10 rows on either side and reuses its elements. It is not AG Grid or Handsontable, and these numbers say nothing about either. We gave it Priena’s data and geometry: 1,000,000 rows of 20 columns in a 1,440 × 900 window. We scrolled each grid for five seconds in three ways: steadily down, diagonally, and to a random place every frame, as when a user drags the scrollbar across a long sheet. The numbers below are medians of five runs on one Apple M4 Pro laptop in Chromium 153; the full method is at the end of this essay.
Neither grid fell behind: in each five-second scroll, each dropped at most one frame out of 300. On the steady scroll, the DOM grid used less of the main thread: 1.7 ms a frame against Priena’s 3.1, out of the 16.7 ms a 60 Hz screen allows. On the jumping scroll, Priena used less, 3.3 ms against 4.4, and the browser spent half as long on style and layout: 0.9 ms a frame against 1.9. With the processor slowed four times, the split held: 3.8 ms against 5.7 on the steady scroll, and 11.9 ms against 7.5 on the jumping one. Priena kept half as many nodes in the page, 610 against 1,225, and most of its nodes belong to the hidden table described below.
Our expectation was wrong. A canvas is not faster on every frame, and our DOM grid did less work than Priena, with no hidden table, no selection, and no editing.
We kept the canvas for two reasons. First, its cost depends only on the screen: Priena’s three scrolls cost 3.1, 3.2, and 3.3 ms, while the DOM grid’s cost rose with how much of the screen changed. Second, a virtualized DOM grid has already lost some of what the DOM gives. Handsontable lists two losses itself: “The browser’s native search will work only for the visible part of the grid,” and “Screen readers may announce the wrong total number of rows.” When the page holds only the visible rows, search and screen reader support have to be built on purpose, whether the cells are elements or pixels.
A canvas grid still scrolls a real element, and browsers cap an element’s length; Chromium’s cap is about 33.5 million CSS pixels. At 34 pixels a row, 1,000,000 rows need 34 million pixels. Priena keeps its scrollbar under 10 million pixels and maps the scroll position to rows in its own code, so at a million rows one pixel of the scrollbar stands for four pixels of content. A drag of the thumb cannot stop on every pixel; the wheel still moves the view by exact amounts.
A canvas and a screen reader
A table of elements tells a screen reader a lot by itself: this is a grid, it has so many rows, this cell is in the third column, this one is selected. A canvas tells it nothing. The HTML standard describes a canvas as “a resolution-dependent bitmap canvas” and makes the author responsible: “when authors use the canvas element, they must also provide content that, when presented to the user, conveys essentially the same function or purpose as the canvas’s bitmap.” The same standard advises against text editing on a canvas: “Authors should avoid implementing text editing controls using the canvas element.” Among its reasons are the caret, copy and paste, spell-checking, bidirectional text, and the input methods people use to type Japanese or Chinese, which “have to be reimplemented.”
So the goal of a million rows on a canvas brings a second requirement with it. Behind Priena’s canvas there is a table of real elements, hidden visually but available to assistive technology. It holds only what is on the screen: the header, the rows in view, and the columns in view. Each row and cell carries its real position in the whole sheet, so a screen reader can say “row 482,193, column D” while only about 25 rows exist as elements. The table also carries state: which cells are selected, which columns are locked, which column is sorted and in which direction, and which cells are still loading from a server. It is updated on every frame that changes something on the screen, and only the changed nodes are touched, so its cost, like the canvas’s, depends on the screen and not on the data.
Focus never moves into that table. It stays on the grid’s element, and the grid points a screen reader at the current cell with aria-activedescendant. The W3C’s authoring practices describe this pattern for a composite widget: when the container supports it, “it is not necessary to manipulate the tabindex attribute and move DOM focus among focusable elements within the container.”
For editing, Priena follows the standard’s advice. When the user starts typing, the grid places a real <input> over the cell and moves focus into it during the same keystroke, without stopping the key. So the first character, a dead key, or the first key of a Japanese composition lands where the browser puts it. The input sits beside the grid’s element, not inside it, because an element with the role of a grid may contain only rows. An automated accessibility checker reported a critical violation when we first put it inside.
Our automated tests run in Chromium only. Safari, Firefox, NVDA, VoiceOver, a real Japanese input method, and the AltGr key on Windows have not been checked on real machines.
The cost
- Writing it ourselves. The grid’s core is about 24,500 lines of TypeScript and the UI kit another 2,300, not counting tests. A team that adopts a component library starts with much of that done.
- A browser floor. The popovers need Chrome 114, Firefox 125, or Safari 17. Older browsers are not supported.
- More work per frame on a steady scroll. The canvas repaints every visible cell each frame: 3.1 ms against the DOM grid’s 1.7.
- Accessibility by hand. We wrote the hidden table ourselves, and it is tested in Chromium only.
- Work the browser would otherwise do. The grid measures and caches text itself. Colors are read from CSS through a hidden element, because a canvas cannot resolve CSS’s
light-dark(). A test that clicks a cell computes where the cell is, because there is no element to click.
What to ask first
Users see a spreadsheet’s features, not the parts under them: rendering, framework boundaries, localization, accessibility, and interaction conventions. On a roadmap these look independent. In Priena’s code, each one limits the others: the canvas requires the hidden table, the framework-free core requires the UI kit, and the popups inside a client’s modal require the browser’s top layer. If you are building or choosing a grid, ask how these parts are built before you compare features.
Unknown today: how the hidden table sounds in VoiceOver and NVDA, how the grid behaves in Safari and Firefox on real machines, and how the canvas compares on a phone or a 120 Hz display.
How we measured
Both grids ran from a production build in headed Chromium 153.0.8010.12 (Playwright 1.63.0), at a device scale factor of 2, in a 1,440 × 900 window, on an Apple M4 Pro with 24 GB of memory under macOS 27.0, on September 28, 2026. The data was 1,000,000 rows of 20 columns from a seeded generator, identical for both and created before either grid mounted. The DOM grid copied Priena’s geometry: rows of 34 pixels, a header of 36, row numbers 76 wide, and columns of 150. Each scroll phase lasted five seconds: steadily down at 12 pixels a millisecond, diagonally, and to a random place every frame. Main-thread time per frame is Chromium’s own count through the DevTools protocol. Each grid ran five times in a fresh browser, the two alternating, and every number above is a median. A separate run read back the cell at each grid’s top-left corner after each phase and compared it with the data: both grids showed the same cell, holding the data’s value. The four-times slowdown used Chromium’s CPU throttling. Limits: one machine, one browser, a 60 Hz display, and a scripted scroll rather than a person’s; memory counts the JavaScript heap only.
Sources
Read 2026-09-28.
- Dan Bricklin, The Idea and Was VisiCalc the “first” spreadsheet?.
- Jakob Nielsen, 10 Usability Heuristics for User Interface Design, Nielsen Norman Group, 1994.
- AG Grid, DOM Virtualisation.
- Handsontable, Row virtualization.
- WHATWG, HTML Standard: the canvas element.
- W3C WAI, ARIA Authoring Practices: Grid pattern and Developing a Keyboard Interface.
- Chromium, layout_unit.h.