alleyinteractive / alleyinteractive/wp-asset-manager

Critical CSS doesn't respect dependency order

Abierto
#22 0 comentarios 0 reacciones 1 asignado Reclamado por @renatonascalves Ver en GitHub
enhancement php
Lenguaje dominante
PHP
Estrellas
30
Forks
5
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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 );
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.