[2.x] bbcode: highlight.js loader runs once per code block and adds ~1.1 s TBT on mobile
Los mantenedores suelen responder en 1 día
@imorland ya está trabajando en esto.
Desde el 16/11/2026.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, php
- Área
- frontend, performance
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- PHP
- Estrellas
- 6.8k
- Forks
- 891
- Merge medio
- 1 d 10 h
- PR fusionados (30 d)
- 209
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de flarum/framework
-
type/accessibility type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Default language is ignored for anyone who chose a language, when the language selector is hiddenPosiblemente ocupada @1AbdullahButt la tomó hace 15 días. Abiertotype/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
Los mantenedores suelen responder en 1 día
-
[2.x] False CLI/Web PHP mismatch when /usr/bin/php differs from the site's FPMPosiblemente ocupada @lazerg la tomó hace 15 días. Abiertotype/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
[2.x] A filter on a resource without a searcher returns a 500Posiblemente ocupada @imorland la tomó hoy. Abiertotype/bug
flarum/framework#5578 · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de flarum/framework
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 87/100
Sylius/Sylius#19359 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Add php 8.6Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 66/100
mailersend/mailersend-php#199 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Tool: somcp_delete_currencyAbiertoConfiguration new tool
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
novalo-dev/Prestashop-MCP-Server#366 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 10 días