Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

      10. Try to limit yourself to using jqLite that Angular comes with rather than full jQuery. This isn't really possibly with any reasonable part of Bootstrap however;
Can you explain this better?


Angular renders the most used parts of JQuery useless, if you use Angular the "right" way. If we do consider it, two of the most used parts of JQuery are $.ajax and querying the DOM.

Because angular already provides you $http and $resource which are more than capable of doing everything that $.ajax does - $.ajax and all its variant that JQuery brings in become redundant.

Because of the way Angular is and because of its philosophy of directives - You generally dont need to query the DOM at all most of the time ( like 90% of the time ). For the rest of the 10% of the time when you do need to query the DOM, you only need to go one step below a directives element (direct children). If you are doing anything more complex, then you are doing something wrong again. For this basic case, Angular already provides you JQLite which is capable of doing the querying for simple scenarios like this.

About the helper functions that JQuery provides - angular too provides quite a few helpers - and they are sufficient for like 95% of the cases. For other stuff you might want to consider underscore.

So, why do you need to include JQuery?


> So, why do you need to include JQuery?

Because it's the foundation of jQuery UI, and JQUI has modules that I don't feel like writing myself from scratch (sortable nested lists).

Still, the joins between Angular and JQUI (through AngularUI) are fairly visible. It's not a smooth ride at the moment.


If you don't include jQuery then Angular falls back to its own home-grown mini-jQuery that they call jqLite, which contains a few essential functions of jQuery. GP was saying that it's sometimes wise to try and only use jqLite if you don't really need some more advanced parts of jQuery. This is presumably to save bandwidth.


jQuery is very large if all you are using is the selector engine and some DOM manipulation.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: