AngularJS vs (AnguarJS + jQuery)

I have a performance question when you only use AngularJS with pure JavaScript and when you use AngularJS with jQuery.

Example:

app.directive('fitHeight', function($window) {
    return {
        restrict: 'A',
        link: function(s){
            s.contentminHeight = $window.innerHeight - 40 + 'px';
            var h = $window.innerHeight;
            $(window).resize(function() {
                if ( h !== $window.innerHeight ) {
                    h = $window.innerHeight;   
                    s.contentminHeight = ( h - 40 ) + 'px';
                    s.$apply();
                }
            });
        }
    };
});

I saw how the check using AngularJS from $ window resizes is outdated, and the other parameters were to create an interval for the check, I found jquery.resize more acceptable.

or

app.directive('leftmenuDropdown', function() {
    return {
        restrict: 'C',
        link: function(s, e){    
            e.click(function(){
                var m = $(e.parent().find("ul")[0]);
                if ( m.hasClass('dd-open') ) { m.removeClass('dd-open') } else { m.addClass('dd-open') }
            });
        }
    };
});

I am searching on google and I realized that .hasClass is faster than pure JavaScript.

About performance, what should I do? To save jQuery using AngularJS or to use only AngularJS with pure JS?

+4
source share
2 answers

Angularjs comes with jqLite

  • , jQuery + Angular , angular.

Angular

  • , jQuery, angular (jqLite).

  • , / .
+3

DOM , :

vanilla - document.getElementById('test-table') => 12,137,211 (ops/sec)
Dojo - dojo.byId('test-table') => 5,443,343 (ops/sec)
Prototype - $('test-table') => 2,940,734 (ops/sec)
jQuery - $('#test-table') => 350,557 (ops/sec)
YUI - YAHOO.util.Dom.get('test-table') =>   326,534 (ops/sec)
MooTools - document.id('test-table') => 78,802 (ops/sec)

. , /. , - . Angular (, ) DOM, Angular, DOM jquery , . , ,

+4

Source: https://habr.com/ru/post/1620073/


All Articles