Improve Enqueued Assets report in Site Health
The current Site Health reports for the Enqueued Assets module, introduced in #25, do not include actionable information for users about how to address a site loading too many enqueued assets. As noted by @felixarntz here:
We also need to think about how to make this warning more actionable, e.g. at a minimum tell users which plugins or themes are responsible for enqueuing the majority of assets etc.
Suggestions for changes (in progress) are below.
Enqueued scripts
If acceptable
Current description: The amount of [#] enqueued scripts (size: [size]) is acceptable.
New description:
If not acceptable
Current description: Your website enqueues [#] scripts (size: [size]). Try to reduce the number or to concatenate them.
More info about performance optimization
Clean Test Cache
New description:
Enqueued styles
If acceptable
Current description: The amount of [#] enqueued styles (size: [size]) is acceptable.
New description:
If not acceptable
Current description: Your website enqueues [#] styles (size: [size]). Try to reduce the number or to concatenate them.
More info about performance optimization
Clean Test Cache
@bethanylang The recommendation "Try to reduce the number or to concatenate them." would only address the number of files problem, not the overall amount of JS/CSS problem. So I think that would only be the first half of the solution. We also need some at least high-level advice for when it's overall too much JS/CSS - which is obviously harder to resolve because concatenating won't reduce that, you would actually need to optimize the code as a developer, or identify which parts of the JS/CSS is maybe not critical (or from a non-critical plugin) so that you can remove it.
I think we should also show only the advice that applies, based on whether the amount of JS/CSS exceeds the threshold or whether the number of files of JS/CSS exceeds the threshold. Or if both, we would show both. But the main point here would be to also provide a recommendation for the first scenario.
For the enqueued scripts the following can be the detailed message.
@felixarntz can this message be improved by adding more links to resources?
I would like to work on this.
@dilipom13 I don't think there's enough definition to work on this yet.
Thank you for the update, @westonruter! I understand. I'll wait for further definition or discussion before proceeding. Please feel free to tag me once it's ready—I’d still love to contribute when the time is right.
I’d like to work on this issue. I plan to enhance the Enqueued Assets test in Site Health to include counts and file sizes of CSS/JS assets for better diagnostics.