开发者

should i use raw javascript or jquery to make an ajax call to get json data

I am building a movie app for my self learning and would li开发者_JS百科ke to know if i should use raw JavaScript or jquery to make my ajax calls for json data from an API? I know that raw JavaScript has a much longer process to implement ajax vs jquery but which performs better?

Kind Regards


I know that raw JavaScript has a much longer process to implement ajax vs jquery but which performs better?

It's not that much longer. The performance is the same either way, as the odd microsecond spent in a library's abstraction layer is completely swamped by the fact you're doing a network call.

Whether you use a library or not is entirely up to you. One benefit of using a library is that, if you choose a popular one, the code has been very thoroughly tested, and you get the benefit of dozens if not hundreds of eyes on it if a new browser has a weird issue in its Ajax or JSON stuff, etc., or when new features come out that require complex inner workings.

Now, if you use a library, which library you choose depends on many factors, and you may well choose jQuery because it's so popular (read: lots of resources familiar with it that can help you) and well-maintained and sponsored, but it's not your only choice by far. You could use Prototype, YUI, Closure, Glow or any of several others...


jQuery, for the half year I have used it, is very reliable. Besides AJAX, there are many built-in functions to make selecting elements, looping, handling events, changing HTML, changing CSS, doing animation a lot easier. Many big corporations use it too. Looks like it is going to stay and become one of the most robust Javascript libraries.

Companies using jQuery: http://docs.jquery.com/Sites_Using_jQuery


Just use jQuery. It's fast enough and well tested. http://api.jquery.com/jQuery.ajax/


You should use jquery. The amount of javascript you will need to write will be significantly less compared to using raw javascript. You will also benefit from readability and maintenance standpoint. Your code will also work among many browsers.


jQuery is much more safe and readable than raw JS. Pure JS performance in this case is not so better to use it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜