nup/web
Daniel Erat 3d9f964205
web: Use textContent instead of innerText.
textContent is standardized and doesn't trigger a reflow on
read (since unlike innerText, it doesn't exclude "hidden"
elements):

https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent
https://kellegous.com/j/2013/02/27/innertext-vs-textcontent/

As far as I can tell, none of my code cares about the
difference in behavior, so use the faster one.

https://stackoverflow.com/q/17199958 (2013) warns that
textContent may be slower when setting, but textContent
now seems to be almost 4 times faster (Chrome 118):

https://www.measurethat.net/Benchmarks/ShowResult/486502

same value, innerText                    1,737,885 ops/sec
same value, textContent                  6,775,336 ops/sec
same value, nodeValue                    4,942,868 ops/sec
same value if changed, innerText         1,107,992 ops/sec
same value if changed, textContent       7,485,101 ops/sec
same value if changed, nodeValue         10,595,588 ops/sec

different value, innerText               1,731,098 ops/sec
different value, textContext             6,572,991 ops/sec
different value, nodeValue               3,845,782 ops/sec
different value if changed, innerText    1,029,156 ops/sec
different value if changed, textContent  7,739,438 ops/sec
different value if changed, nodeValue    10,500,733 ops/sec

I'm not using the nodeValue approach since I suspect it
won't work if I'm trying to update a div that doesn't
already have a text node child.

I'll probably keep the "if changed" checks that I have in
various position-updating code since it apparently doesn't
cost anything and seems like it might still help prevent
paints (I have no idea how it could be faster in the
"different value case, though).
2023-12-03 11:07:45 -04:00
..
LICENSE-fonts.md web: Use inline SVG icons instead of Fontello font. 2022-08-25 12:39:12 -04:00
audio-wrapper.ts web: Make fullscreen-overlay use wake locks. 2023-11-12 20:24:25 -04:00
common.ts web: Use textContent instead of innerText. 2023-12-03 11:07:45 -04:00
config.ts web: Add removeCallback() to Config class. 2023-11-30 08:11:39 -04:00
construct-style-sheets-polyfill.js server, web: Include common CSS in bundle. 2022-05-25 09:24:09 -04:00
dialog.ts web: Use textContent instead of innerText. 2023-12-03 11:07:45 -04:00
favicon-192x192-v1.png web: Cache images and fonts for 2 weeks. 2022-05-25 20:12:06 -04:00
favicon-v1.ico web: Cache images and fonts for 2 weeks. 2022-05-25 20:12:06 -04:00
fontello-config.json web: Add Fontello config. 2022-09-04 17:14:50 -04:00
fontello-v1.woff web: Reintroduce Fontello font for star icons. 2022-09-04 16:11:25 -04:00
fontello-v1.woff2 web: Reintroduce Fontello font for star icons. 2022-09-04 16:11:25 -04:00
fullscreen-overlay.ts web: Use textContent instead of innerText. 2023-12-03 11:07:45 -04:00
global.d.ts web: Remove DOM defs from global.d.ts. 2023-11-13 08:22:00 -04:00
index.html web: Hide focus ring around context menus. 2023-04-19 07:08:47 -04:00
index.ts Support PNG cover images. 2023-10-29 11:41:00 -04:00
manifest.json web: Cache images and fonts for 2 weeks. 2022-05-25 20:12:06 -04:00
maskable-192x192-v1.png web: Cache images and fonts for 2 weeks. 2022-05-25 20:12:06 -04:00
maskable-512x512-v1.png web: Cache images and fonts for 2 weeks. 2022-05-25 20:12:06 -04:00
menu.ts web: Add fullscreen mode option. 2022-07-06 08:51:33 -03:00
options-dialog.ts web: Use textContent instead of innerText. 2023-12-03 11:07:45 -04:00
play-view.ts web: Use textContent instead of innerText. 2023-12-03 11:07:45 -04:00
roboto-v30-latin-regular.woff web: Use inline SVG icons instead of Fontello font. 2022-08-25 12:39:12 -04:00
roboto-v30-latin-regular.woff2 web: Use inline SVG icons instead of Fontello font. 2022-08-25 12:39:12 -04:00
robots.txt go: Use Go modules. 2020-04-08 15:47:19 -04:00
search-view.ts web, server: Support clearing rating with mouse. 2023-11-12 10:35:31 -04:00
song-info-dialog.ts web: Use textContent instead of innerText. 2023-12-03 11:07:45 -04:00
song-table.ts web: Use textContent instead of innerText. 2023-12-03 11:07:45 -04:00
stats-dialog.ts web: Use textContent instead of innerText. 2023-12-03 11:07:45 -04:00
tag-suggester.ts web: Minor tag-suggester autocomplete improvements. 2023-07-14 13:42:38 -04:00
update-dialog.ts web: Use textContent instead of innerText. 2023-12-03 11:07:45 -04:00
updater.ts web, server: Support clearing rating with mouse. 2023-11-12 10:35:31 -04:00