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

オープン
#1,557 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
58/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
活発
技術スタック
php, wordpress
領域
backend

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
PHP
スター
365
フォーク
135
平均マージ
1日 8時間
マージ済み PR(30日)
20

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

WordPress/plugin-check のほかの issue

WordPress/plugin-check の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。