Should I avoid using a JavaScript library while learning how to write AJAX client code? [closed]

Is it better to learn how to code AJAX without the use of an AJAX library? What are the advantages of coding from scratch over using a library such as jQuery?

See also:

What are some of the pros and cons of using jQuery?

For learning, yes, avoid libraries. Especially for something as conceptually simple as AJAX, forcing yourself to learn how the browser can be used “raw” will benefit you immensely later on, even if you are using a library to take care of the drudgery and abstract away browser differences.

Once you have a solid understanding of how it works though, use a library, if for no other reason than spending time working around subtle browser differences is a waste. Better yet though, spending some time reading through the source of jQuery and others will give you insight into what well-written JavaScript looks like – and that in turn will benefit the code you do write!

While I think it is really important to understand conceptually what is going on and be able to correctly implement calls using an AJAX library, I disagree with @Shog9 that you need to write the actual code to perform an XmlHttpRequest in order to start using AJAX. I’d say do some background reading to understand the concepts — implement the code samples demonstrating them if you want — but once you get the concept, find some tutorials on how to do stuff with AJAX with or without libraries. You’ll soon find that others have been there before and left pretty good sign-posts on how to get around.

Read More:   Can You Get A Users Local LAN IP Address Via JavaScript?

I agree with the sentiment about looking at framework code to see how to write good code.

Well it depends…
Do you want so get productive fast? then JQuery or any other framework of your choice is the way.
But if you want to dive in to Javascript/Ajax and learn how stuff works then it would be better to try and write things yourself and also take a look at other frameworks out there and learn from them. Different people have different point of views so look at them and how they’re doing it and learn from that.

Warning: I love jQuery, my opinion is biased

For people that are new with javascript I believe it is important to learn the basics (read: do it from the ground up) rather than rely on libraries. That said the time savings and terseness of the resulting code is well worth using the library.

To recap:
Learning do if yourself
Otherwise do yourself and your deadlines a favour and use the library.

Every generation of technology makes learning the previous generation less useful, even though it could give you more power.

Example: Millions learned Visual Basic even though writing your own C gives you more control.

Answer to the question:
If you want to learn about AJAX, study how the libraries use AJAX. They are open source. They have been matured over time and are commented well.

If you want to USE AJAX, then just use one of the libraries and save yourself a world of headache.

Read More:   addEventListener in Internet Explorer

I think it’s all a matter of what your end goal is. If your looking to have a good fundamental understanding of AJAX so you can make educated decisions about which framework is best and why certain things work then learning AJAX without the help of a framework is best for you. If your goal to learn how to architect dynamic websites and AJAX is the missing link in your understanding, then I see no harm in learning based on a framework. Besides, how often do you really need to understand the fundamentals of a technology. In the same way that you don’t really need to know how to use the WinHttp object to be able to make Http requests in .Net, for the most part you don’t need to know how to use the XmlHttpRequest object because your likely going to be using some form of interface to access it anyway.

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Similar Posts