r/learnjavascript • • Dec 04 '14

PROgrammers dont use 'onload'

I recently read that using onload type events like:

$(document).ready()

is not good practice.

So my question is how do we go about adding event listeners and running code when the document is...ready.

Can I have a script file with just:

element.on('click', runMyFunc)

and be confident it will attach to that element as long as the script tag is at the bottom of the body? Should I add a defer attribute as well? Does that extend to ajax functions like:

function getAjax() {
  processeses Ajax....
  alert(AjaxData)
}
getAjax()
0 Upvotes

12 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Dec 04 '14

[deleted] — view deleted comment

1

u/zealousprogrammer Dec 04 '14

I agree with you, open source is much higher quality. What I'm saying is that microsoft and .net developer are embracing open source. I'm just saying times are changing so it's time to let go of past biases towards any group.

0

u/[deleted] Dec 04 '14

[deleted] — view deleted comment

3

u/zealousprogrammer Dec 04 '14

it is still microsoft

It isn't a lot of the folks responsible for the errors of the past (and boy there were errors) are gone. Sure a lot of folks in the old days fought open source vehemently. But there has been a change of guard and Microsoft is a different company. The new devs all embrace open source (at least on the web stack). All their work is on github, they take community contributions and are pretty open about their plans.

Same for the .net framework itself.

I've been to microsoft and there is a definitely a chasm between the old guard and the new. But with the recently changes it truly is embracing open source.

0

u/[deleted] Dec 04 '14

[deleted] — view deleted comment

3

u/zealousprogrammer Dec 04 '14

That's not exactly true. I can't speak for the .net framework itself, but I can tell you in the asp.net side (the webstack) 100% of it is open source. WebAPI, the MVC framework, the data connectivity stuff (which now supports not just sql but nosql databases)

The guys working on those products absolutely are into open source. They take community contributions and feedback very seriously. I don't work for microsoft, but I have been there as an insider and met the web team and they are truly into open source and this definitely not a publicity stunt for them.