Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
42
rated 0 times [  43] [ 1]  / answers: 1 / hits: 16756  / 8 Years ago, thu, july 21, 2016, 12:00:00

It seems to me that both events are fired when every resource and its dependent resources have finished loading. This rises some questions:




  1. Is there any difference between those events?

  2. Which event gets fired first?

  3. Which event could or should be preferred for adding an additional HTML element to the body after everything has been finished loading?


More From » javascript

 Answers
17

  1. As you say, they both do exactly the same thing. The advantage of addEventListener is that you can add more than one event listener to the load event.



  2. From some basic testing, it seems the listeners get called in the order they were set, though I don't know how reliable that is.



  3. You can use either method to do whatever you need.




[#61296] Monday, July 18, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
magaly

Total Points: 524
Total Questions: 96
Total Answers: 89

Location: India
Member since Wed, Aug 26, 2020
4 Years ago
magaly questions
Wed, May 5, 21, 00:00, 3 Years ago
Sun, Nov 8, 20, 00:00, 4 Years ago
Mon, Oct 21, 19, 00:00, 5 Years ago
Mon, Jul 15, 19, 00:00, 5 Years ago
;