[2.x] bbcode: highlight.js loader runs once per code block and adds ~1.1 s TBT on mobile
I maintainer di solito rispondono entro 1 giorno
@imorland ci sta già lavorando.
Dal 16/11/2026.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, php
- Ambito
- frontend, performance
Direzione di ricerca
Start with extensions/bbcode/src/Configure.php and its adaptHighlightJs() entry point, then inspect the s9e CODE template behavior described in the issue. Compare the loader’s repeated script requests and Lighthouse measurements against the suggested approaches; the issue does not choose a solution, so agree on the design with maintainers before implementation. Done means an agreed approach addresses the performance cost and the opt-out or configuration needs.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
On any discussion with code blocks, the bbcode extension's CODE template makes the browser load s9e/hljs-loader from cdn.jsdelivr.net, and running that loader is a large share of the page's main-thread blocking time.
How it gets there: extensions/bbcode/src/Configure.php adds the CODE BBCode from the s9e repository and adaptHighlightJs() appends a small inline script to the template. The s9e template itself emits <script async data-hljs-style="github" src="https://cdn.jsdelivr.net/gh/s9e/[email protected]/loader.min.js"> inside each <pre>. The rendered HTML therefore contains one loader <script> per code block (10 on the page below), and the loader then fetches highlight.min.js 11.11.0 and a github.min.css from the same CDN.
Measurement: Lighthouse 13.5.0, mobile emulation, 4x CPU slowdown, https://linkrobins.com/d/61-support (Flarum 2.0.2, 10 code blocks), run twice:
- Total Blocking Time 2,790 ms and 2,670 ms.
- Lighthouse "bootup time":
[email protected]/loader.min.jsis the second largest script after forum.js, about 1,159 ms total, 1,117 ms of it scripting.highlight.min.jsadds another ~81 ms. - Performance score 0.36 and 0.38. The page has no other third-party script of significance.
I have not profiled inside the loader, so I can't say how much of the cost is the per-block repeated script elements versus the loader itself.
Suggestions, in no particular order:
- Emit the loader once per post (or once per page) instead of once per code block.
- Load it after load or on idle (
requestIdleCallback), and only highlight blocks when they are near the viewport. - Offer a smaller build with common languages instead of whatever the loader pulls in.
- Provide a config/setting or extender hook to disable syntax highlighting or point it at a self-hosted copy, so forums that care about TBT, CSP or third-party requests can opt out.
I'm not proposing a code change, as this looks like a design decision for the maintainers. Related earlier discussion in s9e/TextFormatter: #193 (customize the hljs load URL) and #206.
- Lingua principale
- PHP
- Stelle
- 6.8k
- Fork
- 891
- Merge medio
- 1g 10h
- PR unite (30g)
- 209
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di flarum/framework
-
type/accessibility type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Default language is ignored for anyone who chose a language, when the language selector is hiddenForse già presa @1AbdullahButt l’ha presa 15 giorni fa. Apertatype/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
I maintainer di solito rispondono entro 1 giorno
-
[2.x] False CLI/Web PHP mismatch when /usr/bin/php differs from the site's FPMForse già presa @lazerg l’ha presa 15 giorni fa. Apertatype/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
[2.x] A filter on a resource without a searcher returns a 500Forse già presa @imorland l’ha presa oggi. Apertatype/bug
flarum/framework#5578 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di flarum/framework
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 87/100
Sylius/Sylius#19359 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Add php 8.6Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 66/100
mailersend/mailersend-php#199 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Tool: somcp_delete_currencyApertaConfiguration new tool
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
novalo-dev/Prestashop-MCP-Server#366 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 10 giorni