Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an aspx page... i have a javascript function and Jquery on page load. Which one is executed first and Why?
Posted

jQuery is a library. jQuery is written in JavaScript, and when you write code with jQuery, you're writing JavaScript. So it's not "faster than JavaScript".
But low quality javascript codes will be slower than jQuery for most cases.
 
Share this answer
 
Comments
Uday P.Singh 31-Aug-11 5:27am    
Agree my 5!
As mentioned by Hasan337, jQuery is just a load of javascript functions wrapped up in an object!

With javascript, the order of execution can be important & where you reference files are important. For example, you couldn't call a jQuery function *before* you've referenced the jQuery source file - the function wouldn't be defined yet.

Have a look at this document anyway, which describes the jQuery $(document).ready()

http://www.learningjquery.com/2006/09/introducing-document-ready[^]

Compared to body.onLoad, the document states...

...Also, it triggers those events when the window loads, which leads me to another advantage of $(document).ready().

With $(document).ready(), you can get your events to load or fire or whatever you want them to do before the window loads. Everything that you stick inside its brackets is ready to go at the earliest possible moment — as soon as the DOM is registered by the browser, which allows for some nice hiding and showing effects and other stuff immediately when the user first sees the page elements.


Based on this, can you answer you're own question?
 
Share this answer
 
Comments
Uday P.Singh 31-Aug-11 5:27am    
my 5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900