r/ProgrammerHumor 2d ago

Meme ancientTools

Post image
5.8k Upvotes

387 comments sorted by

View all comments

Show parent comments

1

u/SolideMeinung 2d ago

Even DOMContentLoaded is not a drop in replacement.

1

u/sixtyhurtz 2d ago

Isn't window.onload the modern vanilla JS replacement? If not I'm interested to hear what the differences are!

1

u/SolideMeinung 2d ago

The ready function of jquery is implemented here: https://github.com/jquery/jquery/blob/main/src/core/ready.js

1

u/sixtyhurtz 2d ago

OK, so it wraps it in the JQuery error handling and also catches the case where the script is run when the DOM is already loaded - so DOMContentLoaded would not fire in that case I guess?

And actually thinking about it, onload waits for big resources like images. So it's nicer to have event handlers attached before that.

1

u/SolideMeinung 2d ago

See thats what i mean with my initial post.

1

u/ExtraWorldliness6916 2d ago

jQuery docs states that it serves a similar purpose, good enough for me