Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it sometimes necessary to use multiple javascript libraries?

I'm new to web development and don't fully understand the role a js framework plays in an app. I've started with jQuery, but people have said I should try prototype.js or node.js for my project, which is a multiplayer strategy game.

Is it important to select a framework early on, and making sure it does everything you need so you don't have to use multiple frameworks?

like image 829
RapsFan1981 Avatar asked Jun 30 '12 19:06

RapsFan1981


People also ask

Should I use JavaScript libraries?

As a developer, having and using the right JavaScript libraries is important. It will make you more productive and will make development much easier and faster. In the end, it is up to you which library to prefer based on your needs.

How many libraries are there in JavaScript?

As we've said, JavaScript libraries are used to perform specific functions. There are around 83 of them, each created to serve some purpose, and we are going to cover some of their usability in this section.

Why do we need JavaScript libraries?

JS frameworks and libraries give developers the ability to use prewritten code for common JavaScript functions, and to create their own functions that can then be reused as needed.

Which JavaScript library is most used?

React. One of the most popular JS-dependent libraries, React. js helps in creating interfaces. It has become the most popular choice of front-end developers to create single-page application user interfaces (UI).


2 Answers

I'm new to web development and don't fully understand the role a js framework plays in an app

You are new but you are lucky!

Few years ago developers had really hard time working around cross browser issues in terms of CSS (still bit of it there), event handling, animations, DOM manipulation. You had to write differnet code for each browser quite often.

The JavaScript libraries came to life and solved the problem of developers, they do all the magic behind the scenes and you write the same code (almost always) to work in each browser. In other words, JavaScript libraries take it on their own to solve cross-browser issues by providing you with consistent set of functions to use for any browser.

Generally, JavaScript libraries take care of these or provide these options:

  • Cross-browser issues handling
  • Animation
  • Custom dialogs and widgets
  • Ability to write lesser code
  • Specific selector engine
  • Creation/Modification of DOM
  • Event Handling
  • Utility Functions
  • AJAX

I've started with jQuery, but people have said I should try prototype.js or node.js for my project, which is a multiplayer strategy game.

Essentially they do the same thing (mentioned above), it is up to you to decide which one you would go for. I like jQuery personally since it is easy to start with and has CSS-Like selector mechanism.

Node.JS is completely different beast, unlike jQuery or Prototype which base on client-side JavaScript, node.js is server-side JavaScript.

Is it important to select a framework early on, and making sure it does everything you need so you don't have to use multiple frameworks?

It isn't important unless you need it eg depending on your needs. Though I would personally suggest you to learn the JavaScript itself first so that when you come to a JavaScript library later, you should be able to make most of it.

like image 86
Blaster Avatar answered Oct 04 '22 15:10

Blaster


The role of a javascript framework is very simple: to give you a set of higher level functionality so that you can build your application without having to recode things which have been done before and to provide a structure for development. You could think of jQuery or prototype.js as sets of functions which other people have found often need to be written again and again so they have already done it for you. Things like animating objects on the screen, or merging and rearranging elements in the DOM are common to many applications so these frameworks and many others try to simplify these common tasks. The other nice thing is they have solved common problems for you in the best possible way for each platform so no matter what browser or phone, you get a similar experience -- this didn't used to be the case.

Node.js is something different. It is a server side language (of course the language is javascript) but it takes the role of php or perl or python or ruby (or your favorite server side lang) in that it actually runs code to talk to databases and fetch pages on the server while the others run code on the users' machines in browsers normally.

I would recommend just choosing one framework and learning it well (my personal vote is jQuery because of the wide developer base, nice plugins, the good documentation, and the understandability of code) but since each of these is just normal javascript under the hood, anything you can't do in one you can bridge with normal javascript. Practically you can do anything in any of them, just some tasks will be simpler in one framework than another. When working with several, while they may not actively conflict it will be a development nightmare.

For your particular application you will need both a front end an backend to make it work. If the app you are trying to build is a website then by all means go with one of these javascript frameworks but if you are talking about a mobile app on android or iphone you don't event need these.

like image 32
hackartist Avatar answered Oct 04 '22 16:10

hackartist