Ajax - Library or plain Javascript

I read a lot about AJAX and wanted to know which one works best: using a library like jQuery, using my built-in methods or creating JavaScript without a library for AJAX?

+7
javascript jquery prototypejs ajax
source share
4 answers

Ajax has many quirks when working with the XMLHttpRequest object. When you start working with him, you will not see him, but when he ends in a production environment, he will bite you in the butt. Browsers, browser version, user preferences, server type, request type and much more can affect what needs to be encoded. Libraries tend to solve most problems, but all of them are not perfect.

I always tell people that it’s great to work with a tutorial to see how XMLHttpRequest works. Once you have learned to do this naked, work with a library that suits your needs.

Eric Pascarello

+20
source share

Why create a library when a lot already exists? If you create a library, it will take time and effort, and in the end you will encounter the same obstacles that others already have. And if your company is not trying to sell the Ajax library, then stay away from writing your own plumbing code.

I am currently using both jQuery and Microsoft Ajax on my site and have found that they both have many options in different ways that you can use to configure communications.

+1
source share

If you ask this question on comp.lang.javascript, you will get many different answers, many of which neglect the widely used libraries (one quote, sometimes taken a little out of context, Richard Kornford's post in cljs in 2007 : "Prototype.js was written people who don’t know javascript for people who don’t know javascript. People who don’t know javascript are not the best source for designing systems using javascript. ")

An argument for libraries - they abstract most of the differences between browsers and allow the use of cross-browser scripts. The argument against libraries is that they are bloated code with their own quirks, so you have to learn to use them just as well as use cross-browser methods in raw javascript. If you write a lot of Javascript that you intend to reuse in several places, and you try to load websites quickly and quickly and use the minimum bandwidth (for example, if you use pay-per-use web hosting, for example via Amazon S3 or nearlyfreespeech. net ), then it’s probably worth stripping everything you intend to use from a good library, configure it and use it.

I thought about Prototype for a while, but then decided that I just needed some simple building blocks. I usually use the Doug Crockford simple JSON library , and then some of the Fork Javascript minimalist libraries as needed (primarily FORK.Ajax ), and do the rest myself from scratch or reuse routines from an earlier project that I honed to which something that works well for me.

+1
source share

why don't you use a library if it suits your needs. are you using .net framework or java JRE or php built-in functions ...

you can create your own javascript for training purposes or do something that libraries do not offer. but for regular development, you use the library much faster and you get compatibility with several JS browsers, without requiring support for cross-browser support manually, it is already built into the library

0
source share

All Articles