Skip to content

Commit

Permalink
Add new redundant async or defer check
Browse files Browse the repository at this point in the history
  • Loading branch information
csswizardry committed Sep 19, 2021
1 parent 6157a36 commit 7ed6bde
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 25 additions & 1 deletion ct.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* custom properties for use later on.
*/

html {
head {
--ct-is-problematic: solid;
--ct-is-affected: dashed;
--ct-notify: #0bce6b;
Expand All @@ -35,6 +35,8 @@ html {

head,
head script,
head script:not([src])[async],
head script:not([src])[defer],
head style, head [rel="stylesheet"],
head script ~ meta[http-equiv="content-security-policy"],
head > meta[charset]:not(:nth-child(-n+5)) {
Expand Down Expand Up @@ -182,6 +184,28 @@ head script[src][src][async][defer] {



/**
* Async and defer simply do not work on inline scripts. It won’t do any harm,
* but it’s useful to know about.
*/
head script:not([src])[async],
head script:not([src])[defer] {
border-style: var(--ct-is-problematic);
border-color: var(--ct-warn);
}

head script:not([src])[async]::before {
content: "The async attribute is redundant on inline scripts"
}

head script:not([src])[defer]::before {
content: "The defer attribute is redundant on inline scripts"
}





/**
* Third Party blocking resources.
*
Expand Down
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

<link rel="stylesheet" href="./style.css?print" media="print" />

<script async>console.log('foo')</script>

<script src="./script.js?after-print"></script>

<link rel="stylesheet" href="./style.css" />
Expand Down

0 comments on commit 7ed6bde

Please sign in to comment.