alleyinteractive / alleyinteractive/wp-asset-manager

Critical CSS doesn't respect dependency order

未关闭
#22 0 条评论 0 个 reaction 已指派 1 人 已被 @renatonascalves 认领 在 GitHub 查看
enhancement php
主要语言
PHP
星标
30
派生
5
PR 合并指标
30 天内没有已合并 PR

描述

When more than one critical CSS file is registered (for example, one from a parent theme and one from a child theme) the dependencies are not respected. They get output in the order in which `add_asset()` is called, not according to their dependencies.

In the code below, `critical-first` should be output first because it's a dependency of `critical-second`, but `critical-second` gets output first because that's the order in which `add_asset()` is called.

```php
$styles = [
[
'condition' => 'global',
'deps' => [
'critical-first',
],
'handle' => 'critical-second',
'load_hook' => 'am_critical',
'load_method' => 'inline',
'src' => MY_PATH . '/critical-second.css',
'version' => 1,
],
[
'condition' => 'global',
'deps' => [],
'handle' => 'critical-first',
'load_hook' => 'am_critical',
'load_method' => 'inline',
'src' => MY_PATH . '/critical-first.css',
'version' => 1,
],

];

array_map( [ \Asset_Manager_Styles::instance(), 'add_asset' ], $styles );
```

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。