DEV Community

Using jQuery with Angular 6. Is it best practice?

RippleCRM on August 08, 2019

Hi There, We are currently building an application in angular and node. Part of our application involves a calendar with a drag and drop functiona...
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.