La technique CSS ingénieuse de Harry offre des informations sur les performances en analysant votre élément. Un aspect clé consiste à rendre les éléments cachés visibles en modifiant leur propriété <code>display
- une astuce simple mais efficace applicable même à contenu. Par exemple:
tête, style de tête, script de tête { Affichage: bloc; }
L'éclat de Harry brille dans ses sélecteurs sophistiqués, identifiant les goulots d'étranglement des performances basés sur l'utilisation et le placement des étiquettes. Par exemple, un<script> tag appearing after stylesheets:</script>
<link href="..." rel="stylesheet"><title>Page Title</title>
is inefficient, as the script execution is blocked by the CSS. While specialized performance tools can detect this, Harry leverages CSS selectors:
head [rel="stylesheet"]:not([media="print"]):not(.ct) ~ script, head style:not(:empty) ~ script { /* Styles applied here for visual debugging */ }
This refined selector targets only stylesheets or style blocks that are actually causing blocking, excluding those with media="print"
or the .ct
class. Harry then uses styling and pseudo-elements to visually highlight these performance issues within the stylesheet itself, transforming it into a visual performance debugging tool.
This clever approach allows the stylesheet to flag various issues, including unnecessary attributes, blocking resources, and incorrectly ordered elements. The sheer ingenuity of using CSS in this way is remarkable.
Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!