Skip to content

Commit 40a1e07

Browse files
authored
Add new Scripts section with async, defer, and integrity examples
2 parents a62de9e + f80eb69 commit 40a1e07

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- [Elements](#elements)
1313
- [Meta](#meta)
1414
- [Link](#link)
15+
- [Scripts](#scripts)
1516
- [Icons](#icons)
1617
- [Social](#social)
1718
- [Facebook Open Graph](#facebook-open-graph)
@@ -269,6 +270,38 @@ These elements provide information for how a document should be perceived, and r
269270

270271
- 📖 [Link Relations](https://www.iana.org/assignments/link-relations/link-relations.xhtml)
271272

273+
## Scripts
274+
275+
```html
276+
<!--
277+
Scripts: place <script> tags at the end of <body> when possible.
278+
The following attributes control loading behavior when placed in <head>:
279+
-->
280+
281+
<!-- Blocks HTML parsing and content rendering until the script is fetched and executed -->
282+
<script src="script.js"></script>
283+
284+
<!-- The script will be fetched in parallel with parsing and executed as soon as it is available (before parsing completes) -->
285+
<script async src="script.js"></script>
286+
287+
<!-- The script will be fetched in parallel with parsing and executed when the page has finished parsing -->
288+
<script defer src="script.js"></script>
289+
290+
<!-- async takes precedence in modern browsers; defer acts as a fallback for older browsers that don't support async -->
291+
<script async defer src="script.js"></script>
292+
293+
<!-- Inline script -->
294+
<script>
295+
// function(s) go here
296+
</script>
297+
298+
<!-- Subresource Integrity (SRI): use the integrity attribute to verify that the fetched resource has been delivered without unexpected manipulation -->
299+
<script src="https://example.com/script.js" integrity="sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC"></script>
300+
```
301+
302+
- 📖 [async vs defer attributes](https://www.growingwiththeweb.com/2014/02/async-vs-defer-attributes.html)
303+
- 📖 [Subresource Integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity)
304+
272305
## Icons
273306

274307
```html

0 commit comments

Comments
 (0)