Mixing Javascript libraries in a project

Asked

Viewed 678 times

8

I wonder if it is not good practice to load several different Javascript libraries in one application.

For example, the project has an X deadline for delivery, but should be done in Angularjs but the developer knows more about jQuery which makes the development of the project faster. Over time he acquires knowledge of directivas of Angularjs and decides to include this library in the source code along with jQuery and replacing certain business rule for the layout that could do with jQuery and now implemented with Angularjs.

Until when is it recommended to do this practice? Why not do everything using Angularjs or another library? Any article that addresses this or a response with good arguments about it?

2 answers

9


Angular is a framework, jQuery is a bilioteca. The two can live in the same project quietly.

The problem is if you want to use two frameworks or two libraries that fulfill the same goal.

For example, the combinations below would not be recommended:

  • Jquery and Zepto
  • Angular and Ember
  • Google Maps and Leaflet

You can even see projects that do this kind of combination, but this is a sign that probably the rest of the code should be very messy and difficult to maintain.

Edit:

Just to complement: in practice, a web project in production usually use dozens (in some cases even hundreds) of libraries at the same time time. A framework is nothing more than a collection of libraries made to work together.

It is recommended that you use a package manager for your project, like Bower, to keep its libraries organized.

  • Thank you for your reply, very clear. Zepto, and Leaflet did not know about them.

  • 2

    @Giancarlogiulian Just adding, Angular makes use of jQuery. Along with Angular, comes a lib called jQueryLite, which is a reduced version of jQuery. If in your HTML you include the full jQuery before Angular, Angular will make use of full jQuery instead of jQueryLite.

  • Interesting @Viníciusgobboa.deOliveira

  • 3

    Well put, @Viníciusgobboa.deOliveira. I’m not particularly an Angular user and I don’t know much about it. In the case of frameworks I prefer Ember or, depending on the project, something more "light" like Backbone (which also uses jQuery as one of its dependencies).

  • Excellent discussion, was going through the same "dilemma" but after some research I saw that each has its specific use, and well separated as framework and lib... richer applications for users..

2

I was going to open up a similar topic so I’ll leave my opinion here.

This depends a lot on the frameworks involved.

Jquery + Angular: Not a good practice

The angular is a reactive framework. Internally it uses a timeout that looks at the scope variables. Whenever something changes it updates the page with the content. You do not access the DOM directly and use the concept single page which greatly improves application performance.

The jquery has a totally different approach. It uses DOM access to retrieve and set information. This access is not recommended due to loss of application performance. I’m not going to get into the merits of how it works because I’d be dealing with a topic that’s not on topic.

React + Jquery: Not a good practice

The React is a template-oriented framework. It also has the concept of single page and is reactive as the angular. I do not consider it a good practice precisely because the framework itself already has everything you need. Besides, it’s lighter than angular because its core is smaller. So it doesn’t make sense to include another js framework to do something that React already does.

React + Angular: Not a good practice

Even though both are reactive and using concept single page the structure and way of development is different. Mixing both can generate a fruit salad that will more confuse than help. Remember that development with angular is particularly faster and has more features. However the React is lighter besides being used and maintained by facebook. Nor do I need to go deeper to state that it is also a good option.

In short

These are some of the leading frameworks available in the market. Those I mentioned are widely used in the front-end community, have good documentation with several examples available on the net. So there’s no reason to use more than one.

I know how the IT market works. Pressure for deliveries and etc. More changing the course of the project because someone does not know of the resource used is a team problem. If you are a programmer you have an obligation to know all the technologies used by the team precisely to not have this kind of problem. Now if it is a bean with rice and the company accepts it is because the company is not focused on the quality of source code and later on the quality of the project for the customer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.