47.8 per cent of the characters in our 111 page files are sentences, and 93 of those files contain no logic at all
Every URL on PubTrivia is a TypeScript file. There are 111 of them in the sitemap and 111 page.tsx files behind them, one each, no dynamic segments on the public side. So the repository is not really a program with conte
Every URL on PubTrivia is a TypeScript file. There are 111 of them in the sitemap and 111 page.tsx files behind them, one each, no dynamic segments on the public side. So the repository is not really a program with content in it. It is a stack of writing with a program holding it up, and I wanted to know the exact ratio.
$ curl -s https://pub-trivia.app/sitemap.xml | grep -o '<loc>[^<]*' | sed 's|<loc>||' > urls.txt
$ wc -l urls.txt
111
Then for each URL, read app/<path>/page.tsx, parse it with the TypeScript compiler API, and classify every character.
Method, including what I counted as copy
A string literal of 40 or more characters that contains a space is copy. Shorter ones are labels, class names, icon names, paths and keys, and I counted them as code. JSX text nodes of three characters or more are copy too, which matters for exactly three pages (below). Everything else is structure.
Greps are useless for this, by the way. JSX text is not a string literal, and the legal pages are nothing but JSX text, so a regex pass over the same files reports those three as having almost no words in them.
The totals
| Measure | Value |
|---|---|
| Sitemap URLs | 111 |
page.tsx files behind them |
111 |
| Lines of source | 17,436 |
| Characters of source | 843,398 |
| Characters of copy (strings plus JSX text) | 403,083 |
| Copy share of source | 47.8% |
| String literals in those files | 7,165 |
| HTML delivered by the live site | 8,792,696 B |
| Visible text delivered | 642,137 chars |
| HTML bytes per character of copy written | 21.8 |
| Brotli bytes per character of copy written | 3.34 |
Nearly half of every file is prose. The median page is 168 lines and 7,598 characters, the smallest is 60 lines and the largest 403.
93 of 111 files have no logic in them
| Shape | Count |
|---|---|
Pages rendering through the shared ContentPage component |
106 of 111 |
| Pages with 4 to 6 imports | 97 of 111 |
| Pages with more than 9 imports | 3 of 111 |
| Pages containing any function or arrow beyond the default export | 18 of 111 |
So 93 of the 111 files are a default export returning one component call, wrapped around a data structure. The page is an array of sections, each with a heading and some paragraphs, and the component decides what a section looks like. Nothing in those 93 files branches, loops, fetches or computes.
The 18 that do contain a function are the five tools, which have real client components, and the hubs, which map over a list of child pages.
The spread
Copy share is not uniform, and the pattern is editorial rather than technical:
| Page | Copy share of source |
|---|---|
/guides/writing-quiz-questions |
68.0% |
/guides/how-to-be-a-good-quizmaster |
67.1% |
/solutions/care-homes |
67.0% |
/guides/pub-quiz-scoring-systems |
65.8% |
/features/multi-venue |
50.8% |
/tools |
26.3% |
/quiz-questions (hub) |
26.0% |
/ (homepage) |
23.2% |
/guides (hub) |
20.5% |
Fourteen pages are over 60 per cent copy. They are all guides and venue pages, which exist to say something at length. The five lowest are all hubs and the homepage, which exist to point at other pages: their characters go on links, grids and layout, not sentences.
The extremes in absolute terms are a single seasonal quiz page at 17,796 characters of source, and /features/multi-venue at 2,941. The large one is long because it is a list of questions, which is a format I am not going to quote from here, and the small one is 60 lines that still deliver 54,109 bytes of HTML.
Three pages write their prose the other way round
The three legal documents are the only hand-written pages left on the public site, and they hold their copy as JSX text rather than as data:
| Page | Source chars | In string literals | In JSX text |
|---|---|---|---|
/legal/privacy |
11,270 | 300 | 5,278 |
/legal/terms |
10,746 | 326 | 4,975 |
/legal/cookies |
4,017 | 253 | 1,357 |
Those three carry 11,610 of the 14,325 characters of JSX text on the entire site, which is 81 per cent of it. Every other page puts its sentences in an array, where a component can count them, a test can read them and a hub can quote them. The legal pages put theirs in markup, where nothing can. That is also why they are the only three pages with no entry in the content registry, no breadcrumb trail and a different footer, which I measured separately a while back.
The 1.59x, and where the extra words come from
The pages deliver 642,137 characters of visible text but their own files contain 403,083 characters of copy. The difference is 239,054 characters, about 2,154 per page, and none of it is written in the page it appears on:
- The header and footer, repeated 111 times.
- Each page's breadcrumb trail.
- The lede paragraph under the title, which is the page's registry description.
- The related-link cards at the foot, whose titles and summaries are other pages' registry entries.
lib/content/registry.ts is 1,518 lines with 1,184 string literals, 18,467 characters of which are prose, 109 description fields and 109 related arrays. One file supplies the title, the meta description, the visible lede, the breadcrumb label, the sitemap entry and the sideways links for everything. It is the single most read-from text file in the project, and no page contains the sentences it contributes.
21.8 bytes of HTML per character written
A character of copy becomes 21.8 bytes of delivered HTML, or 3.34 bytes once the CDN compresses it. A character of source, copy and code alike, becomes 10.4 bytes.
The multiplier is not waste in the usual sense. It is class attributes, the duplicated flight payload React ships for hydration, the navigation and the footer, and the structured data block. I have measured those pieces individually in earlier posts: class attributes alone are about 13 per cent of the bytes, and each page's own description appears between six and twelve times in one response. But if you ever want the fastest honest estimate of what a content page costs to ship, multiplying the characters you typed by 21.8 is startlingly close on this site.
What this measurement gets wrong
The 40-character threshold is arbitrary and it under-counts. "Start free, no card needed" is copy by any sane definition and 26 characters long, so it lands in the code bucket on 68 pages. Button labels, aria labels and section terms are all shorter than the threshold. The true copy share is higher than 47.8 per cent, and I would rather state a floor than tune a threshold until it flatters the number.
It also only looks at the 111 page files. Components contribute strings of their own, the registry contributes 18,467 more characters of prose, and the seed data in utils is mostly text as well, so the repository's overall writing share is not the same number as this one.
The visible-text count comes from stripping tags out of the delivered HTML with a regular expression after removing script blocks, which is accurate to a few hundred characters per page and no better. And the two sides of the comparison are not the same corpus: the source is what we wrote, the delivered text is what a reader sees, and the gap between them is the point rather than an error.
Why I think the number matters
A repository that is half prose has a review problem that no tooling in a JavaScript project is pointed at. Types cannot check whether a sentence is true. The test suite here does check the things that can be checked, which is title and description length budgets and the internal consistency of the registry, and on a good day it catches a hub whose description claims a number of child pages that no longer matches. It cannot catch a paragraph that went out of date, which is a different job and belongs to a person with a date in a calendar.
The pages are all live if you would like to read some of what those characters became: the guides are at pub-trivia.app/guides, the venue pages at pub-trivia.app/solutions, and the three JSX-text outliers at pub-trivia.app/legal/privacy. The product the writing is about is free to start, no card, at pub-trivia.app.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.