I have a rather large application which, on the admin frontend, takes a few seconds to load a page because of all the pageviews that it has to load into objects before displaying anything. Its a bit complex to explain how the system works, but a few of my other questions explains the system in great detail. The main difference between what they say and the current system is that the customer frontend no longer loads all the pageviews into objects when a customer first views the page - it simply adds the pageview to the database and creates an object in an unsynchronised list... to put it simply, when a customer views a page it no longer loads all the pageviews into objects; but the admin frontend still does.
I have been working on some admin tools on the customer frontend recently, so if an administrator clicks the description of an item in the catalogue then the right hand column will display statistics and available actions for the selected item. To do this the page which gets loaded (through $('action-container').load(bla bla bla);
) into the right hand column has to loop through ALL the pageviews - this ultimately means that ALL the pageviews are loaded into objects if they haven't been already. For some reason this loads really REALLY fast. The difference in speed is only like a second on my dev site, but the live site has thousands of pageviews so the difference is quite big...
So my question is: why is it that the admin frontend loads so slowly while using $(bla).load(bla);
is so fast? I mean whatever method jQuery uses, can't browsers use this method too and load pages super-fast? Obviously not as someone would've done that by now - but I am interested to know just why the difference is so big... is it just my system or is there a major difference in speed between the browser getting a page and jQuery getting a page? Do other people experience the same kind of differences?
jQuery has own layer which translate into native JavaScript , so definitely native JavaScript will be faster.
jQuery in terms of speed is quite fast for modern browsers on modern computers. So is pure JavaScript. Both run drastically slower on older browsers and machines. Pure Javascript to access the DOM can be faster as you can cut the overhead that jQuery has on this.
IT is the commonly the first library that JavaScript developers learn because: Its syntax for AJAX calls is very simple compared to the native XmlHttpRequest. It offers shorthand solutions to common JavaScript challenges, like sorting and filtering arrays. Many other libraries have jQuery dependencies.
Nearly all plain Javascript functions will be faster than jQuery operations. This is because jQuery has overhead in creating a jQuery object in order to be more flexible, allow for chaining, support collections, etc...
I mean whatever method jQuery uses, can't browsers use this method too and load pages super-fast?
jQuery only has available to it that which the browser provides (the DOM API). Nothing more. jQuery brings nothing extra to the table, and performs no magic tricks.
It is basically just a layer over that API, as such, it is actually slower than if you just used the API directly.
...this has received so many up votes suggests that other people experience the same speed increase when using jQuery.
You received upvotes because you praised jQuery for being fast. I think this is evidenced by the fact that none of these upvoters bothered to point out that jQuery can not somehow be faster than the browser.
If you had criticized jQuery, I'm guessing you would have been downvoted by some users.
Facebook has done a lot of research into this area (loading pages in parts by Javascript rather than all at once).
See their "BigPipe" technology explained here: http://www.facebook.com/notes/facebook-engineering/bigpipe-pipelining-web-pages-for-high-performance/389414033919
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With