+ 1
Question on JavaScript
what is the difference between declaring script tag in head section and declaring it in body section
10 Answers
+ 9
if you put it at the end of the body tag, first the whole html will load and then the script, so you don't have to use things like window.onload in your script because you can assume that the dom is ready
+ 9
@visph give me a sec, i can change that
+ 9
firstly SL is monitoring us as well, they see every post I have hidden or edited, secondly they discuss potential moderators with the current mods before giving them the rank thirdly you only get those "superpowers" after 6 months of moderating
+ 7
@visph Thanks! I didn't know that! ^^
+ 6
@Michal Jakubec:
<< In body it improves the speed of display >>
... ONLY IF IT'S PUTTED AT END OF BODY: if you put it at body start, that will not make any difference.
Also, simple web pages will not have a sensitive difference in the delay to be displayed, and it's almost advised to use 'DOMContentLoaded' event from document object rather than 'onload' one from window (equivalent to this one of <body>), to avoid waiting for external ressources fully loaded before being fired when you have big/heavy pictures linked to your web document ;)
('DOMContentLoaded' event require to be instanciated through the addEventListener() JS method, contrarly to 'onload' wich can be used by assigning the object related property -- window.onload=myfunction / document.body.onload=myfunction)
+ 4
in body it improves the speed of display
+ 4
^^
New mods tools seems to be very intrusive: I hope (but unfortunally don't guess) that sololearn will be vigilant to who is able to have such power ;P
+ 4
@Kamil: I'm happy to note that those "new" powers aren't "new general" powers and that they are only attributed to 6 months old moderators ;)
+ 3
Really @Kamil?
Glad to inform you so ^^
@DINESH DAS:
In what the @Kamil last answer deserve the best answer mark? @@
+ 1
thank you