Timeline for How to make JavaScript execute after page load?
Current License: CC BY-SA 4.0
32 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 1, 2023 at 17:20 | history | edited | Inigo | CC BY-SA 4.0 |
The standard is that the `load` event fires on `window`, not `document`, tho the latter often works
|
Dec 29, 2022 at 23:55 | history | edited | Inigo | CC BY-SA 4.0 |
added another "right moment" option to the answer to make it even more complete.
|
Oct 4, 2022 at 11:24 | history | edited | robstarbuck | CC BY-SA 4.0 |
Small typo
|
May 30, 2022 at 23:05 | comment | added | DevWL | @RayLoveless yes, I meant defer. So JavaScript pauses render of the DOM there for, the best way would be to place it at the bottom of the page or to load JavaScript script with defer attribute (placed in the header). Thanks | |
May 28, 2022 at 15:10 | history | edited | DevWL | CC BY-SA 4.0 |
added 118 characters in body
|
May 28, 2022 at 14:44 | history | edited | DevWL | CC BY-SA 4.0 |
deleted 1 character in body
|
May 28, 2022 at 14:37 | history | edited | DevWL | CC BY-SA 4.0 |
deleted 1 character in body
|
May 28, 2022 at 14:14 | history | edited | DevWL | CC BY-SA 4.0 |
added 683 characters in body
|
May 28, 2022 at 13:59 | history | edited | DevWL | CC BY-SA 4.0 |
added 683 characters in body
|
May 28, 2022 at 13:53 | history | edited | DevWL | CC BY-SA 4.0 |
added 683 characters in body
|
May 28, 2022 at 13:48 | history | edited | DevWL | CC BY-SA 4.0 |
added 683 characters in body
|
May 28, 2022 at 13:30 | history | edited | DevWL | CC BY-SA 4.0 |
added 424 characters in body
|
May 28, 2022 at 12:15 | history | edited | DevWL | CC BY-SA 4.0 |
added 105 characters in body
|
May 28, 2022 at 12:10 | history | edited | DevWL | CC BY-SA 4.0 |
added 105 characters in body
|
May 28, 2022 at 10:51 | history | edited | DevWL | CC BY-SA 4.0 |
added 105 characters in body
|
Mar 4, 2022 at 17:41 | comment | added | RayLoveless | @DevWL, I think you meant "defer"... because "async" can still execute before the all the html loads. | |
Dec 7, 2021 at 13:14 | history | edited | Matthias Braun | CC BY-SA 4.0 |
spelling
|
Jan 24, 2020 at 11:58 | comment | added | wkille |
+1 I tried window.onload = ... thinking that my script would wait until everything was fully downloaded before running but it seems window.onload actually behaves like document.addEventListener("DOMContentLoaded", ... , whereas the window.addEventListener("load", ... really does wait for everything to be fully downloaded. I would have thought that window.onload should be equivalent to window.addEventListener("load", ... rather than document.addEventListener("DOMContentLoaded", ... ?? I got the same result in Chrome and FF.
|
|
Jan 13, 2020 at 7:29 | history | edited | Antonio Laguna | CC BY-SA 4.0 |
Typo fix
|
Apr 30, 2019 at 20:18 | comment | added | ToolmakerSteve | Re asynchronous javascript: to clarify, there are two choices for scripts that don't immediately run. Of those, defer is usually preferable to async - because defer won't interrupt html parsing/rendering - and when it runs, DOM is guaranteed to be ready. Efficiently load JavaScript with defer and async. | |
Jan 24, 2019 at 10:26 | comment | added | tfont | This is the most completed answer. onload is after, but people don't realize this at first. | |
S Nov 14, 2017 at 15:05 | history | suggested | JFoxx64 | CC BY-SA 3.0 |
Removed uneeded semicolon at the end of the last bit of code and a few characters from the divider line to allow the change
|
Nov 14, 2017 at 14:42 | review | Suggested edits | |||
S Nov 14, 2017 at 15:05 | |||||
S Oct 24, 2017 at 20:27 | history | edited | gyc | CC BY-SA 3.0 |
Just spelling and typos to ease reading
|
S Oct 24, 2017 at 20:27 | history | suggested | Antoine | CC BY-SA 3.0 |
Just spelling and typos to ease reading
|
Oct 24, 2017 at 19:53 | review | Suggested edits | |||
S Oct 24, 2017 at 20:27 | |||||
Oct 3, 2017 at 18:43 | history | edited | DevWL | CC BY-SA 3.0 |
added 29 characters in body
|
Sep 25, 2017 at 22:37 | history | edited | DevWL | CC BY-SA 3.0 |
added 177 characters in body
|
Sep 25, 2017 at 22:22 | history | edited | DevWL | CC BY-SA 3.0 |
added 706 characters in body
|
Sep 25, 2017 at 22:13 | history | edited | DevWL | CC BY-SA 3.0 |
added 706 characters in body
|
Jul 18, 2017 at 14:59 | comment | added | arodebaugh | @Peter pretty sure this stands alone probably best if it in the bottom of your javascript files so it executes last | |
Mar 19, 2016 at 0:50 | history | answered | DevWL | CC BY-SA 3.0 |