Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitad8e0c8

Browse files
authored
async vs defer js
1 parent242c2f9 commitad8e0c8

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,3 +359,18 @@ window.addEventListener('contextmenu', ()=>{
359359
return false // cancel default menu
360360
},false)
361361
```
362+
363+
364+
# In HTML5, you can tell the browser when to run your JavaScript code
365+
```javascript
366+
367+
//Without async or defer, browser will run your script immediately, before rendering the elements that'sbelowyourscripttag.
368+
<scriptsrc="myscript.js"></script>
369+
370+
//With async (asynchronous), browser will continue to load the HTML page and render it while the browser load and execute the script at the same time.
371+
//Async is more useful when you really don't care when the script loads and nothing else that is user dependent depends upon that script loading.(for scripts likes Google analytics)
372+
<scriptasyncsrc="myscript.js"></script>
373+
374+
//With defer, browser will run your script when the page finished parsing. (not necessary finishing downloading all image files.
375+
<scriptdefersrc="myscript.js"></script>
376+
```

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp