Share dependency-size logic between the enqueued scripts and styles checks

Abierto
#1,557 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
58/100
Tipo de issue
Refactorización
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
php, wordpress
Área
backend

Línea de trabajo

Read Enqueued_Scripts_Size_Check and Enqueued_Styles_Size_Check, then inspect the dependency counting added for #1488 and the discussion on #74. Extract the shared dependency traversal, URL to file resolution, size counting, threshold check, and warning into a reusable base or trait while preserving each check’s registry, handle filter, and warning message. Done means styles count dependencies, including inline code and core dependencies, and both checks use the shared logic.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

What problem does it solve?

Enqueued_Scripts_Size_Check and Enqueued_Styles_Size_Check are near-identical: both walk the enqueued handles for a plugin, resolve each one to a local file, add up the bytes, and warn past a threshold. #1488 taught the scripts check to also count the dependencies a handle pulls in (recursively, de-duplicated, including inline before/after code and core deps like jQuery). The styles check still only measures the plugin's own files.

So after #1488 the two checks diverge. A plugin whose stylesheet depends on a large shared stylesheet stays under the radar, while the equivalent script does not. On #74 the suggestion was to converge the two first so this logic lives in one place:

Might be easiest to first converge this class with Enqueued_Styles_Size_Check (e.g. by adding an abstract class or trait) so this logic can be reused.

#1488 kept its scope to the scripts check to stay reviewable, so this is the tracked follow-up.

Proposed approach

Pull the shared parts (dependency walk, src-to-path resolution across the URL roots, file and inline size counting, the threshold comparison and warning) into an abstract base or a trait, and have both size checks extend or use it. The scripts and styles registries share the same WP_Dependencies shape, so the walk is the same; the per-check pieces are the registry (wp_scripts() vs wp_styles()), the handle filter, and the warning code and message.

Outcome: dependency counting applies to stylesheets too, and the two checks can't drift apart again.

Happy to take this on once #1488 lands.

Lenguaje dominante
PHP
Estrellas
365
Forks
135
Merge medio
1 d 8 h
PR fusionados (30 d)
20

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de WordPress/plugin-check

Todos los issues de WordPress/plugin-check

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.