DEV Community

RippleCRM
RippleCRM

Posted on

Using jQuery with Angular 6. Is it best practice?

Hi There,

We are currently building an application in angular and node. Part of our application involves a calendar with a drag and drop functionality where events can be moved between the different days. 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. I haven't found anything on what this impacts on security either but it would be great if anyone can share any feedback with regards to this.

So questions are if anyone can help:

  1. Is it possible to build the above functionality in Angular without using jQuery?

  2. Is it advised to use jQuery with Angular?

  3. Are there any security implications for using jQuery with Angular? (for example also in the scenario if there are scripts that have jQuery libraries even that aren't used on the platform but are contained with another script)

Many Thanks in advance!

Top comments (2)

Collapse
 
bradtaniguchi profile image
Brad

Is it best practice?

no, unless you want to use a lib that relies on jQuery.


Generally you can use any client-side lib with Angular, and only end up dealing with some change detection issues, but JQuery's use-cases of DOM manipulation should be handled by Angular itself, along with most of its utility methods, like .ajax As such jQuery by itself has no reason to be added to an Angular app. There could be a library that you may want to use that rely on jQuery, in this case you can add it and not worry.

  1. Yes, you should have no major problems using and integrating jQuery into your Angular app.

  2. No, you should only use it if you need it to use something else that requires jQuery. jQuery itself doesn't provide anything Angular provides out of the box.

  3. Its possible jQuery executed code could by-pass Angular's built in security, such as its built in sanitation. This goes for any external lib and not just jQuery. Generally if a JS script is included on the page, it could be a security risk. How and what that script can do usually is more important.

Collapse
 
louis profile image
Louis Augry

For drap&drop, test the Angular Material CDK.

And please don't use JQuery on Angular !!!!!! It's an insult.