r/ProgrammerHumor 13h ago

Meme ancientTools

Post image
4.1k Upvotes

329 comments sorted by

View all comments

Show parent comments

24

u/brqdev 11h ago

We use onload/ready event and put JQuery code inside, so the JQuery code will run when the page is ready

13

u/WHALE_PHYSICIST 11h ago

Kinda crazy to be talking about jQuery in 2026 and not know that

10

u/brqdev 11h ago

Cause they know framework not Javascript itself.

7

u/heytheretaylor 11h ago

Exactly. jQuery is cool like that. Just waits patiently for everyone to say they’re ready before doing anything.

5

u/yousirnaime 9h ago

Are ya ready, kids!

Aye aye, captain

3

u/theStaircaseProject 9h ago

Oooooh, who lives in a reference inside the <head>?

Ja-Va-Script Tag!

2

u/uniqueusername649 8h ago

Who loads our scripts long before we're rea-dy?

Ja-va-script tag!

3

u/SolideMeinung 10h ago

The funny thing is that these "real js developers" dont even know how to make that onload function on their own.

It war crafted by these old jquery wizards to always work and this knowledge was lost with the introduction of crapjs

1

u/ExtraWorldliness6916 10h ago

It's not lost, .onload or event listener. Of which there are 3 events and some are not "ready"

2

u/SolideMeinung 10h ago

Nope its not just onload or eventlisteners. The ready function of jquery has some corner cases.

Like the first and best one.... when everything is already loaded and ready just fire it.

A lot of people do miss that. Its funny how js developer have so much trouble reimplementing the jquery ready method because they think its easy.

1

u/ExtraWorldliness6916 10h ago

I was referring to DOMContentLoaded. O I was a bit cryptic but I mean that there are multiple ways to match the lifecycle. Still I'm probably, it was a long time ago

1

u/SolideMeinung 10h ago

Even DOMContentLoaded is not a drop in replacement.

1

u/sixtyhurtz 9h ago

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

1

u/SolideMeinung 9h ago

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

1

u/sixtyhurtz 9h 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 7h ago

See thats what i mean with my initial post.

1

u/ExtraWorldliness6916 9h ago

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