Repository navigation
perf(theme): add a core web vitals baseline - #195
francoistibo wants to merge 4 commits into
Conversation
Give projects opt-in LCP images, sized static images, a low-priority logo, idle JS init, and scroll-free animations so new themes start closer to good CWV scores. Co-authored-by: Cursor <cursoragent@cursor.com>
Write image width/height into dist/image-dimensions.json at build time and resolve them from the memoized manifest at runtime to avoid N+1 filesystem I/O in loops. Keep a per-request filesystem fallback for assets outside the build. Drop default decoding=sync on is_lcp and document manifest-based CLS helpers. Co-authored-by: Cursor <cursoragent@cursor.com>
ee1bf8c to
e245d85
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e245d85. Configure here.
|
|
||
| if (!sharp) { | ||
| return null | ||
| } |
There was a problem hiding this comment.
Raster dimensions never hit the manifest
Low Severity
The dimensions plugin reads raster files only through sharp, which is not a package dependency (it is an optional peer of image-minimizer-webpack-plugin and is not installed). require('sharp') always fails, so PNG/JPEG/WebP/AVIF never land in dist/image-dimensions.json. Runtime fallback still reads the files, so CLS is preserved, but the build-time cache this PR adds does not apply to rasters such as default.webp.
Reviewed by Cursor Bugbot for commit e245d85. Configure here.
Co-authored-by: Cursor <cursoragent@cursor.com>


Dotez les projets d'images LCP « opt-in », d'images statiques redimensionnées, d'un logo à faible priorité, d'une initialisation JavaScript en mode veille et d'animations sans défilement, afin que les nouveaux thèmes démarrent avec des scores CWV plus proches de la moyenne.
Résumé
get_the_image()(is_lcp) :fetchpriority="high",decoding="sync", pas deloading="lazy".fetchpriority="high"n'est jamais combiné avecloading="lazy".get_theme_static_image_markup()/the_theme_static_image():widthetheightlus dans le fichier du thème (SVG ou raster) pour limiter le CLS. Unaltvide est rendualt=""(image décorative) ;falseounullretire l'attribut.alt=""quand l'appelant le demande sur une image de la médiathèque, pour que les technologies d'assistance ignorent l'image.fetchpriority="low", pour qu'il ne concurrence pas la vraie image LCP.bea_theme_framework_preload_fonts. La liste est vide par défaut : seuls les fichiers réellement affichés au premier rendu doivent y figurer.Animationpar unIntersectionObserverpartagé. Les options (start,end,playOnce,hideOnReachEnd) et les callbacks (onInit,onShow,onHide,onDestroy) restent les mêmes.deferInitialization()pour lancer le JavaScript non critique au repos du navigateur (INP).robots.txt, cache, fonts, embeds tiers) dans le README.deferInitializationest exposé surwindow.beapi.utilspour les assets partiels (wp-block,wp-pattern,template).Plan de test
the_image()avec'is_lcp' => trueproduitfetchpriority="high",decoding="sync"et aucunloading="lazy".the_image()avec'alt' => ''produitalt="".the_theme_static_image()sur un SVG qui awidthetheightreprend ces attributs etalt="".fetchpriority="low".bea_theme_framework_preload_fonts, aucun<link rel="preload" as="font">n'est imprimé..js-animation-opacityreçoitis-visibleen entrant dans le viewport, et reste masqué avant.prefers-reduced-motionet l'impression désactivent toujours les animations.window.beapi.utils.deferInitializationest disponible après le chargement du bundle common.Note
Medium Risk
Animation visibility timing changes site-wide front-end behavior; image/LCP attribute changes affect rendering and accessibility if misused.
Overview
Adds a Core Web Vitals baseline for theme projects: README guidance plus PHP/JS/build hooks teams can opt into.
Images:
get_the_image()gainsis_lcp(drops lazy loading, setsfetchpriority="high") and honors explicitalt=""for decorative media. Newthe_theme_static_image/get_theme_static_image_markuphelpers outputdist/assets with default decorative alt, optional dimensions fromdist/image-dimensions.json(generated at build by a new webpack plugin), and the same fetchpriority/lazy rules.Performance service: Opt-in font preloads via
bea_theme_framework_preload_fonts; custom logo images getfetchpriority="low".JS:
Animationswitches from scroll polling to sharedIntersectionObserver(with a no-IO fallback);deferInitializationis exposed onwindow.beapi.utilsfor idle-time non-critical work.SCSS: Minor Dart Sass updates (
meta.type-of,math.is-unitless) and removal of debug output inem().Reviewed by Cursor Bugbot for commit 7d6c339. Bugbot is set up for automated code reviews on this repo. Configure here.