Skip to content

Commit 290e4c2

Browse files
authored
Merge pull request #18 from SRedCodes/master
added comments related to readystatechnage , loading state of HTML do…
2 parents 5e8040a + 4375606 commit 290e4c2

File tree

1 file changed

+9
-3
lines changed
  • JavaScript/Event Listeners/js

1 file changed

+9
-3
lines changed

JavaScript/Event Listeners/js/main.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ click:
55
mouseover:
66
mouseout:
77
submit:
8-
change:*/
8+
change: etc..*/
99

1010
//selecting a view//
1111
const view = document.querySelector("#view2");
@@ -32,13 +32,19 @@ view3.style.display = "flex";
3232
// event.target.textContent ="clicked";
3333
// })
3434

35-
document.onreadystatechange = () =>{ // onreadystatechange defines a function to be executed when readyState changes(loading /interactive/ complete)
36-
if(document.readyState === "complete"){ //readyState retrives a value that indicates the state of document.
35+
document.onreadystatechange = () =>{ // onreadystatechange defines a function to be executed when readyState is changed.
36+
if(document.readyState === "complete"){ //readyState retrives a value that indicates the state(loading /interactive/ complete) of document.
3737
console.log("ready state completed");
3838
initApp();
3939
}
4040
}
4141

42+
/*HTML document has multiple states:
43+
loading --> html doc is not loaded and parsed
44+
interactive --> html doc is loaded and parsed i.e DOM tree is loaded however the supporting scripts,images,stylesheets are still loading, this indiacted "DOMContentLoaded" event is about to fire.
45+
complete --> html doc and all supporting scripts ,images, stylesheets are loaded and "load" event is about to fire.
46+
*/
47+
4248
const initApp = ()=>{
4349
const div = view.querySelector("div");
4450
const h2 = div.querySelector("h2");

0 commit comments

Comments
 (0)