From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 From: Milan Hauth Date: Mon, 26 Feb 2024 21:03:40 +0100 Message-ID: Subject: immediately show content of large text files To: list+cgit@causal.agency Content-Type: text/plain; charset="UTF-8" currently the rendering of large text files is not ideal example: 800 KiB html file with 25K lines rendering times plain text file: 7 seconds cgit: 18 seconds github: 30 seconds (lazy loading on scroll) gitea: 50 seconds sourcehut: "800 KiB large file not shown." one problem with cgit: cgit first shows the line numbers and then the file contents so the first 16 seconds i see only line numbers and empty space on the right side i suggest to fix the "line numbers first" issue by rendering numbers and contents in parallel
1<!DOCTYPE html>
2
3<html>
4
5<!-- some comment -->
6
7<body>

i generated the 
 content with

grep -n "" | sed -E 's|&|\&|g; s|<|\<|g;
s|^([0-9]+):|\1|'

optimizations:
">" dont need escaping
attributes dont need quotes

for my file that means 7% smaller

to compare:

grep -n "" | sed -E 's|&|\&|g; s|<|\<|g; s|>|\>|g;
s|^([0-9]+):|\1|'

> cgit: 18 seconds

my version renders in maybe 17 seconds...
but more important:
the file content is visible immediately