0

Whats the difference between these three ways of normally calling a function? Searched everywhere and found single explanations of each, but not in a comparison of all these three relatieve to eachother. How do these three compare?

A.
window.onload = LaunchGallery();

B.
$(function(){LaunchGallery();}

C.
$(window).on('load', function() {LaunchGallery();});

If there are other standard ways welcome to add and make the comparison more comprehensive

I'm aware that the $(document).ready(function(){}); is for JQuery functions only. The scope of this question however is for general, standard, non framework dependant Javascript ways of calling a function into existence during, at or after pageload or any other moment during the lifespan of a webpage).

Sam
  • 15,254
  • 25
  • 90
  • 145
  • A is broken. B and C depend on jQuery so are out of scope as per the final paragraph of the question. – Quentin May 20 '22 at 10:33
  • Thank you for your comment. Why is A broken? By Broken do you mean it should be avoided alltogether in todays modern browsers? I will investigate the two links you provided. Thank you! – Sam May 20 '22 at 22:34

0 Answers0