Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it a bad practice to use jQuery in Angular? [closed]

My question is the following. Should I avoid using any kind of jQuery code in Angular application as it seems legit to have only one thing interacting with DOM. Another question is if anyone came across problems where he couldn't find any other solution but writing a quick hack with jQuery.

Thank YOU!

like image 500
Davit Karapetyan Avatar asked Nov 29 '18 08:11

Davit Karapetyan


People also ask

Is jQuery useful with Angular?

jQuery is a small yet feature-rich powerful javascript library that helps to manipulate the HTML DOM with less javascript code. We can use jQuery with Angular. There are some situations you come across while building Angular apps that it's absolutely necessary to use a library like jQuery to get something done.

Is it bad practice to use jQuery?

It's a bad practice because React uses a concept called a Virtual DOM instead of a real DOM. And React isn't aware of the changes made outside of this Virtual DOM. When you use jQuery or any other library that manipulates the DOM, React gets confused.

Is it a good or bad practice to use AngularJS together with jQuery?

We have recently found out that the development team has build this functionality by using jQuery instead of Angular. From what I have researched so far, using jQuery in an Angular platform is bad practice and can make the platform more complicated for management and updates.

Is it OK to use JavaScript in Angular?

For an angular application it is not a proper way to run javascript out of scope of angular. It will ensure that the external function exist before starting app. It will add more flexibility and control over the java script function in angular.


2 Answers

Yes it's a bad practice, but sometimes it will save you much time, especially when you are looking for a plugin, Do it when necessary only, and keep a note to switch it back when other solutions are available.

like image 108
amd Avatar answered Oct 05 '22 22:10

amd


Well it's just two large resources, which makes your app "heavy". Otherwise it's only a preference thing. Personally I don't use jQuery with any of the reactive frameworks (Vue, React nor Angular).
Remember that anything jQuery can do, you can do with vanilla JS.

like image 29
Borisu Avatar answered Oct 05 '22 22:10

Borisu