├── .gitignore ├── .idea ├── .name ├── encodings.xml ├── misc.xml ├── modules.xml ├── ng-perf.iml ├── scopes │ └── scope_settings.xml └── vcs.xml ├── README.md ├── bower.json ├── demo-app ├── angular ├── app.js ├── bower_components │ ├── angular-route │ │ ├── .bower.json │ │ ├── README.md │ │ ├── angular-route.js │ │ ├── angular-route.min.js │ │ ├── angular-route.min.js.map │ │ ├── bower.json │ │ └── package.json │ ├── bower_components │ │ └── ng-perf │ │ │ ├── .bower.json │ │ │ ├── bower.json │ │ │ └── lib │ │ │ ├── ng-perf-patches.js │ │ │ └── ngpLocalEventDirs.js │ ├── jquery │ │ ├── .bower.json │ │ ├── MIT-LICENSE.txt │ │ ├── bower.json │ │ ├── dist │ │ │ ├── jquery.js │ │ │ ├── jquery.min.js │ │ │ └── jquery.min.map │ │ └── src │ │ │ ├── ajax.js │ │ │ ├── ajax │ │ │ ├── jsonp.js │ │ │ ├── load.js │ │ │ ├── parseJSON.js │ │ │ ├── parseXML.js │ │ │ ├── script.js │ │ │ ├── var │ │ │ │ ├── nonce.js │ │ │ │ └── rquery.js │ │ │ └── xhr.js │ │ │ ├── attributes.js │ │ │ ├── attributes │ │ │ ├── attr.js │ │ │ ├── classes.js │ │ │ ├── prop.js │ │ │ ├── support.js │ │ │ └── val.js │ │ │ ├── callbacks.js │ │ │ ├── core.js │ │ │ ├── core │ │ │ ├── access.js │ │ │ ├── init.js │ │ │ ├── parseHTML.js │ │ │ ├── ready.js │ │ │ └── var │ │ │ │ └── rsingleTag.js │ │ │ ├── css.js │ │ │ ├── css │ │ │ ├── addGetHookIf.js │ │ │ ├── curCSS.js │ │ │ ├── defaultDisplay.js │ │ │ ├── hiddenVisibleSelectors.js │ │ │ ├── support.js │ │ │ ├── swap.js │ │ │ └── var │ │ │ │ ├── cssExpand.js │ │ │ │ ├── getStyles.js │ │ │ │ ├── isHidden.js │ │ │ │ ├── rmargin.js │ │ │ │ └── rnumnonpx.js │ │ │ ├── data.js │ │ │ ├── data │ │ │ ├── Data.js │ │ │ ├── accepts.js │ │ │ └── var │ │ │ │ ├── data_priv.js │ │ │ │ └── data_user.js │ │ │ ├── deferred.js │ │ │ ├── deprecated.js │ │ │ ├── dimensions.js │ │ │ ├── effects.js │ │ │ ├── effects │ │ │ ├── Tween.js │ │ │ └── animatedSelector.js │ │ │ ├── event.js │ │ │ ├── event │ │ │ ├── alias.js │ │ │ └── support.js │ │ │ ├── exports │ │ │ ├── amd.js │ │ │ └── global.js │ │ │ ├── intro.js │ │ │ ├── jquery.js │ │ │ ├── manipulation.js │ │ │ ├── manipulation │ │ │ ├── _evalUrl.js │ │ │ ├── support.js │ │ │ └── var │ │ │ │ └── rcheckableType.js │ │ │ ├── offset.js │ │ │ ├── outro.js │ │ │ ├── queue.js │ │ │ ├── queue │ │ │ └── delay.js │ │ │ ├── selector-native.js │ │ │ ├── selector-sizzle.js │ │ │ ├── selector.js │ │ │ ├── serialize.js │ │ │ ├── sizzle │ │ │ └── dist │ │ │ │ ├── sizzle.js │ │ │ │ ├── sizzle.min.js │ │ │ │ └── sizzle.min.map │ │ │ ├── traversing.js │ │ │ ├── traversing │ │ │ ├── findFilter.js │ │ │ └── var │ │ │ │ └── rneedsContext.js │ │ │ ├── var │ │ │ ├── arr.js │ │ │ ├── class2type.js │ │ │ ├── concat.js │ │ │ ├── hasOwn.js │ │ │ ├── indexOf.js │ │ │ ├── pnum.js │ │ │ ├── push.js │ │ │ ├── rnotwhite.js │ │ │ ├── slice.js │ │ │ ├── strundefined.js │ │ │ ├── support.js │ │ │ └── toString.js │ │ │ └── wrap.js │ └── ng-perf │ │ ├── .bower.json │ │ ├── README.md │ │ ├── bower.json │ │ └── lib │ │ ├── ng-perf-patches.js │ │ └── ngpLocalEventDirs.js ├── directives │ └── randomButton.js ├── expressions │ ├── expressions-ctrl.js │ └── expressions-view.html ├── index.html └── ng-repeat │ ├── bind-once.html │ ├── class-expression.html │ ├── complex-expressions.html │ ├── direct.html │ ├── expression-bind.html │ ├── ng-bind.html │ ├── ng-class.html │ ├── ng-repeat-data-100.json │ ├── ng-repeat-data-1000.json │ ├── ng-style.html │ ├── repeat-ctrl.js │ ├── repeat-template.html │ └── repeat-view.html └── lib ├── ng-perf-patches.js └── ngpLocalEventDirs.js /.gitignore: -------------------------------------------------------------------------------- 1 | angular/ 2 | node_modules/ 3 | _site/ 4 | .idea/ 5 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | ng-perf -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/ng-perf.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /.idea/scopes/scope_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ng-perf is a set of utilities to help with AngularJS performance. 2 | 3 | 4 | ngp-local-* 5 | =========== 6 | 7 | A set of events that invoke $scope.digest() instead of $rootScope.apply. This will help with directives where the result of events only needs to be applied to the current scope and downward instead of all the way from rootScope. These events also provide a way to supress the digest altogether via preventDefault method. 8 | 9 | To use directives 10 | 11 | ``` 12 | bower install ng-perf 13 | ``` 14 | 15 | Include ngPerfLocalDirectives.js and add module ngPerf.directives as a dependency 16 | 17 | 18 | Here's an example directive using ngp-local-click. 19 | 20 | ```javascript 21 | 22 | angular.module('ngPerf.randomButton', ['ngPerf.directives']) 23 | .directive('randomButton', function() { 24 | return { 25 | restrict: 'EA', 26 | scope: {}, 27 | controller: function($scope) { 28 | $scope.randomNumber = '123'; 29 | $scope.generateRandom = function() { 30 | $scope.randomNumber = Math.floor(Math.random()*100); 31 | // event.preventDefault(); //uncomment to suppress digest altogether 32 | } 33 | }, 34 | template: '', 35 | link: function(){} 36 | }; 37 | }); 38 | 39 | ``` 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ng-perf", 3 | "version": "0.1.0", 4 | "homepage": "https://github.com/ansukla/ng-perf", 5 | "authors": [ 6 | "Ambika Sukla " 7 | ], 8 | "description": "add-ons to improve angularjs app performance", 9 | "keywords": [ 10 | "perfmatters", 11 | "angularjs" 12 | ], 13 | "main": [ 14 | "lib/ngpLocalEventDirs.js" 15 | ], 16 | "license": "MIT", 17 | "ignore": [ 18 | "**/.*", 19 | "node_modules", 20 | "bower_components", 21 | "test", 22 | "demo-app", 23 | "tests" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /demo-app/angular: -------------------------------------------------------------------------------- 1 | /Users/ambikasukla/projects/angular.js/build/ -------------------------------------------------------------------------------- /demo-app/app.js: -------------------------------------------------------------------------------- 1 | angular.module('NgPerf', [ 2 | 'NgPerf.controllers', 3 | 'blah', 4 | 'ngRoute', 5 | 'ngPerf.directives', 6 | 'ngPerf.randomButton' 7 | ]). 8 | config(['$routeProvider', '$compileProvider', function($routeProvider, $compileProvider) { 9 | $routeProvider. 10 | when("/repeat", {templateUrl: "ng-repeat/repeat-view.html", controller: "repeatController"}). 11 | when("/bind-once", {templateUrl: "ng-repeat/bind-once.html", controller: "repeatController"}). 12 | when("/expression-bind", {templateUrl: "ng-repeat/expression-bind.html", controller: "repeatController"}). 13 | when("/ng-bind", {templateUrl: "ng-repeat/ng-bind.html", controller: "repeatController"}). 14 | when("/direct", {templateUrl: "ng-repeat/direct.html", controller: "repeatController"}). 15 | when("/ng-class", {templateUrl: "ng-repeat/ng-class.html", controller: "repeatController"}). 16 | when("/ng-style", {templateUrl: "ng-repeat/ng-style.html", controller: "repeatController"}). 17 | when("/class-expression", {templateUrl: "ng-repeat/class-expression.html", controller: "repeatController"}). 18 | when("/expression", {templateUrl: "ng-repeat/complex-expressions.html", controller: "repeatController"}). 19 | when("/expressions", {templateUrl: "expressions/expressions-view.html", controller: "expressionsController"}). 20 | otherwise({redirectTo: '/direct'}); 21 | $compileProvider.debugInfoEnabled(false); 22 | }] 23 | ); -------------------------------------------------------------------------------- /demo-app/bower_components/angular-route/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-route", 3 | "version": "1.3.0", 4 | "main": "./angular-route.js", 5 | "dependencies": { 6 | "angular": "1.3.0" 7 | }, 8 | "homepage": "https://github.com/angular/bower-angular-route", 9 | "_release": "1.3.0", 10 | "_resolution": { 11 | "type": "version", 12 | "tag": "v1.3.0", 13 | "commit": "73a3cc8371603e22e32b6dc5354116f73b91e164" 14 | }, 15 | "_source": "git://github.com/angular/bower-angular-route.git", 16 | "_target": "~1.3.0", 17 | "_originalSource": "angular-route", 18 | "_direct": true 19 | } -------------------------------------------------------------------------------- /demo-app/bower_components/angular-route/README.md: -------------------------------------------------------------------------------- 1 | # bower-angular-route 2 | 3 | This repo is for distribution on `bower`. The source for this module is in the 4 | [main AngularJS repo](https://github.com/angular/angular.js/tree/master/src/ngRoute). 5 | Please file issues and pull requests against that repo. 6 | 7 | ## Install 8 | 9 | Install with `bower`: 10 | 11 | ```shell 12 | bower install angular-route 13 | ``` 14 | 15 | Add a ` 19 | ``` 20 | 21 | And add `ngRoute` as a dependency for your app: 22 | 23 | ```javascript 24 | angular.module('myApp', ['ngRoute']); 25 | ``` 26 | 27 | ## Documentation 28 | 29 | Documentation is available on the 30 | [AngularJS docs site](http://docs.angularjs.org/api/ngRoute). 31 | 32 | ## License 33 | 34 | The MIT License 35 | 36 | Copyright (c) 2010-2012 Google, Inc. http://angularjs.org 37 | 38 | Permission is hereby granted, free of charge, to any person obtaining a copy 39 | of this software and associated documentation files (the "Software"), to deal 40 | in the Software without restriction, including without limitation the rights 41 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 42 | copies of the Software, and to permit persons to whom the Software is 43 | furnished to do so, subject to the following conditions: 44 | 45 | The above copyright notice and this permission notice shall be included in 46 | all copies or substantial portions of the Software. 47 | 48 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 49 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 50 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 51 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 52 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 53 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 54 | THE SOFTWARE. 55 | -------------------------------------------------------------------------------- /demo-app/bower_components/angular-route/angular-route.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | AngularJS v1.3.0 3 | (c) 2010-2014 Google, Inc. http://angularjs.org 4 | License: MIT 5 | */ 6 | (function(p,e,B){'use strict';function u(q,h,f){return{restrict:"ECA",terminal:!0,priority:400,transclude:"element",link:function(a,b,c,g,x){function y(){k&&(f.cancel(k),k=null);l&&(l.$destroy(),l=null);m&&(k=f.leave(m),k.then(function(){k=null}),m=null)}function w(){var c=q.current&&q.current.locals;if(e.isDefined(c&&c.$template)){var c=a.$new(),g=q.current;m=x(c,function(c){f.enter(c,null,m||b).then(function(){!e.isDefined(s)||s&&!a.$eval(s)||h()});y()});l=g.scope=c;l.$emit("$viewContentLoaded"); 7 | l.$eval(v)}else y()}var l,m,k,s=c.autoscroll,v=c.onload||"";a.$on("$routeChangeSuccess",w);w()}}}function z(e,h,f){return{restrict:"ECA",priority:-400,link:function(a,b){var c=f.current,g=c.locals;b.html(g.$template);var x=e(b.contents());c.controller&&(g.$scope=a,g=h(c.controller,g),c.controllerAs&&(a[c.controllerAs]=g),b.data("$ngControllerController",g),b.children().data("$ngControllerController",g));x(a)}}}p=e.module("ngRoute",["ng"]).provider("$route",function(){function q(a,b){return e.extend(new (e.extend(function(){}, 8 | {prototype:a})),b)}function h(a,e){var c=e.caseInsensitiveMatch,g={originalPath:a,regexp:a},f=g.keys=[];a=a.replace(/([().])/g,"\\$1").replace(/(\/)?:(\w+)([\?\*])?/g,function(a,e,c,b){a="?"===b?b:null;b="*"===b?b:null;f.push({name:c,optional:!!a});e=e||"";return""+(a?"":e)+"(?:"+(a?e:"")+(b&&"(.+?)"||"([^/]+)")+(a||"")+")"+(a||"")}).replace(/([\/$\*])/g,"\\$1");g.regexp=new RegExp("^"+a+"$",c?"i":"");return g}var f={};this.when=function(a,b){f[a]=e.extend({reloadOnSearch:!0},b,a&&h(a,b));if(a){var c= 9 | "/"==a[a.length-1]?a.substr(0,a.length-1):a+"/";f[c]=e.extend({redirectTo:a},h(c,b))}return this};this.otherwise=function(a){"string"===typeof a&&(a={redirectTo:a});this.when(null,a);return this};this.$get=["$rootScope","$location","$routeParams","$q","$injector","$templateRequest","$sce",function(a,b,c,g,h,p,w){function l(b){var d=r.current;(u=(n=k())&&d&&n.$$route===d.$$route&&e.equals(n.pathParams,d.pathParams)&&!n.reloadOnSearch&&!v)||!d&&!n||a.$broadcast("$routeChangeStart",n,d).defaultPrevented&& 10 | b&&b.preventDefault()}function m(){var t=r.current,d=n;if(u)t.params=d.params,e.copy(t.params,c),a.$broadcast("$routeUpdate",t);else if(d||t)v=!1,(r.current=d)&&d.redirectTo&&(e.isString(d.redirectTo)?b.path(s(d.redirectTo,d.params)).search(d.params).replace():b.url(d.redirectTo(d.pathParams,b.path(),b.search())).replace()),g.when(d).then(function(){if(d){var a=e.extend({},d.resolve),b,c;e.forEach(a,function(d,b){a[b]=e.isString(d)?h.get(d):h.invoke(d,null,null,b)});e.isDefined(b=d.template)?e.isFunction(b)&& 11 | (b=b(d.params)):e.isDefined(c=d.templateUrl)&&(e.isFunction(c)&&(c=c(d.params)),c=w.getTrustedResourceUrl(c),e.isDefined(c)&&(d.loadedTemplateUrl=c,b=p(c)));e.isDefined(b)&&(a.$template=b);return g.all(a)}}).then(function(b){d==r.current&&(d&&(d.locals=b,e.copy(d.params,c)),a.$broadcast("$routeChangeSuccess",d,t))},function(b){d==r.current&&a.$broadcast("$routeChangeError",d,t,b)})}function k(){var a,d;e.forEach(f,function(c,g){var f;if(f=!d){var h=b.path();f=c.keys;var l={};if(c.regexp)if(h=c.regexp.exec(h)){for(var k= 12 | 1,m=h.length;k", 21 | "license": "MIT", 22 | "bugs": { 23 | "url": "https://github.com/angular/angular.js/issues" 24 | }, 25 | "homepage": "http://angularjs.org" 26 | } 27 | -------------------------------------------------------------------------------- /demo-app/bower_components/bower_components/ng-perf/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ng-perf", 3 | "homepage": "https://github.com/ansukla/ng-perf", 4 | "authors": [ 5 | "Ambika Sukla " 6 | ], 7 | "description": "add-ons to improve angularjs app performance", 8 | "keywords": [ 9 | "perfmatters", 10 | "angularjs" 11 | ], 12 | "license": "MIT", 13 | "ignore": [ 14 | "**/.*", 15 | "node_modules", 16 | "bower_components", 17 | "test", 18 | "demo-app", 19 | "tests" 20 | ], 21 | "_release": "26d5606508", 22 | "_resolution": { 23 | "type": "branch", 24 | "branch": "master", 25 | "commit": "26d56065084cab17a89e61256e2430d598b25a20" 26 | }, 27 | "_source": "git://github.com/ansukla/ng-perf.git", 28 | "_target": "*", 29 | "_originalSource": "ng-perf", 30 | "_direct": true 31 | } -------------------------------------------------------------------------------- /demo-app/bower_components/bower_components/ng-perf/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ng-perf", 3 | "version": "0.1.0", 4 | "homepage": "https://github.com/ansukla/ng-perf", 5 | "authors": [ 6 | "Ambika Sukla " 7 | ], 8 | "description": "add-ons to improve angularjs app performance", 9 | "keywords": [ 10 | "perfmatters", 11 | "angularjs" 12 | ], 13 | "license": "MIT", 14 | "ignore": [ 15 | "**/.*", 16 | "node_modules", 17 | "bower_components", 18 | "test", 19 | "demo-app", 20 | "tests" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /demo-app/bower_components/bower_components/ng-perf/lib/ng-perf-patches.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * License: MIT 4 | * @Description: Shameless hacks to workaround angular performance bottlenecks 5 | * 6 | */ 7 | //Bypass .data calls with argument $binding improves ng-bind and {{}} expression binding performance 8 | //Applies to 1.2 only 9 | if (jQuery) { 10 | var originalFn = $.fn.data; 11 | $.fn.data = function() { 12 | if (arguments[0] !== '$binding') 13 | return originalFn.apply(this, arguments); 14 | } 15 | } -------------------------------------------------------------------------------- /demo-app/bower_components/bower_components/ng-perf/lib/ngpLocalEventDirs.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * 5 | * License: MIT 6 | * @Description: ngp-local-* directives are very similar to ng-* event directives such as ng-click etc. except that 7 | * it calls digest on the immediate scope instead of $rootScope.$digest(). Additionally calling preventDefault on the event 8 | * stops digest calls. 9 | * 10 | */ 11 | 12 | angular.module('ngPerf.directives', []); 13 | angular.forEach( 14 | 'click dblclick mousedown mouseup mouseover mouseout mousemove mouseenter mouseleave keydown keyup keypress submit focus blur copy cut paste'.split(' '), 15 | function(eventName) { 16 | var directiveName = 'ngpLocal' + eventName.charAt(0).toUpperCase() + eventName.substr(1); 17 | angular.module('ngPerf.directives').directive(directiveName, ['$parse', function($parse) { 18 | return { 19 | restrict: 'A', 20 | compile: function($element, attr) { 21 | var fn = $parse(attr[directiveName]); 22 | return function localEventHandler(scope, element) { 23 | element.on(eventName, function(event) { 24 | var callback = function() { 25 | fn(scope, {$event:event}); 26 | }; 27 | scope.$eval(callback); 28 | if (!event.isDefaultPrevented()) { 29 | scope.$digest(); 30 | } 31 | }); 32 | }; 33 | } 34 | }; 35 | }]); 36 | } 37 | ); 38 | -------------------------------------------------------------------------------- /demo-app/bower_components/jquery/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery", 3 | "version": "2.1.1", 4 | "main": "dist/jquery.js", 5 | "license": "MIT", 6 | "ignore": [ 7 | "**/.*", 8 | "build", 9 | "speed", 10 | "test", 11 | "*.md", 12 | "AUTHORS.txt", 13 | "Gruntfile.js", 14 | "package.json" 15 | ], 16 | "devDependencies": { 17 | "sizzle": "1.10.19", 18 | "requirejs": "2.1.10", 19 | "qunit": "1.14.0", 20 | "sinon": "1.8.1" 21 | }, 22 | "keywords": [ 23 | "jquery", 24 | "javascript", 25 | "library" 26 | ], 27 | "homepage": "https://github.com/jquery/jquery", 28 | "_release": "2.1.1", 29 | "_resolution": { 30 | "type": "version", 31 | "tag": "2.1.1", 32 | "commit": "4dec426aa2a6cbabb1b064319ba7c272d594a688" 33 | }, 34 | "_source": "git://github.com/jquery/jquery.git", 35 | "_target": "~2.1.1", 36 | "_originalSource": "jquery", 37 | "_direct": true 38 | } -------------------------------------------------------------------------------- /demo-app/bower_components/jquery/MIT-LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2014 jQuery Foundation and other contributors 2 | http://jquery.com/ 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /demo-app/bower_components/jquery/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jquery", 3 | "version": "2.1.1", 4 | "main": "dist/jquery.js", 5 | "license": "MIT", 6 | "ignore": [ 7 | "**/.*", 8 | "build", 9 | "speed", 10 | "test", 11 | "*.md", 12 | "AUTHORS.txt", 13 | "Gruntfile.js", 14 | "package.json" 15 | ], 16 | "devDependencies": { 17 | "sizzle": "1.10.19", 18 | "requirejs": "2.1.10", 19 | "qunit": "1.14.0", 20 | "sinon": "1.8.1" 21 | }, 22 | "keywords": [ 23 | "jquery", 24 | "javascript", 25 | "library" 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /demo-app/bower_components/jquery/src/ajax/jsonp.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core", 3 | "./var/nonce", 4 | "./var/rquery", 5 | "../ajax" 6 | ], function( jQuery, nonce, rquery ) { 7 | 8 | var oldCallbacks = [], 9 | rjsonp = /(=)\?(?=&|$)|\?\?/; 10 | 11 | // Default jsonp settings 12 | jQuery.ajaxSetup({ 13 | jsonp: "callback", 14 | jsonpCallback: function() { 15 | var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) ); 16 | this[ callback ] = true; 17 | return callback; 18 | } 19 | }); 20 | 21 | // Detect, normalize options and install callbacks for jsonp requests 22 | jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { 23 | 24 | var callbackName, overwritten, responseContainer, 25 | jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ? 26 | "url" : 27 | typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data" 28 | ); 29 | 30 | // Handle iff the expected data type is "jsonp" or we have a parameter to set 31 | if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) { 32 | 33 | // Get callback name, remembering preexisting value associated with it 34 | callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ? 35 | s.jsonpCallback() : 36 | s.jsonpCallback; 37 | 38 | // Insert callback into url or form data 39 | if ( jsonProp ) { 40 | s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName ); 41 | } else if ( s.jsonp !== false ) { 42 | s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName; 43 | } 44 | 45 | // Use data converter to retrieve json after script execution 46 | s.converters["script json"] = function() { 47 | if ( !responseContainer ) { 48 | jQuery.error( callbackName + " was not called" ); 49 | } 50 | return responseContainer[ 0 ]; 51 | }; 52 | 53 | // force json dataType 54 | s.dataTypes[ 0 ] = "json"; 55 | 56 | // Install callback 57 | overwritten = window[ callbackName ]; 58 | window[ callbackName ] = function() { 59 | responseContainer = arguments; 60 | }; 61 | 62 | // Clean-up function (fires after converters) 63 | jqXHR.always(function() { 64 | // Restore preexisting value 65 | window[ callbackName ] = overwritten; 66 | 67 | // Save back as free 68 | if ( s[ callbackName ] ) { 69 | // make sure that re-using the options doesn't screw things around 70 | s.jsonpCallback = originalSettings.jsonpCallback; 71 | 72 | // save the callback name for future use 73 | oldCallbacks.push( callbackName ); 74 | } 75 | 76 | // Call if it was a function and we have a response 77 | if ( responseContainer && jQuery.isFunction( overwritten ) ) { 78 | overwritten( responseContainer[ 0 ] ); 79 | } 80 | 81 | responseContainer = overwritten = undefined; 82 | }); 83 | 84 | // Delegate to script 85 | return "script"; 86 | } 87 | }); 88 | 89 | }); 90 | -------------------------------------------------------------------------------- /demo-app/bower_components/jquery/src/ajax/load.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core", 3 | "../core/parseHTML", 4 | "../ajax", 5 | "../traversing", 6 | "../manipulation", 7 | "../selector", 8 | // Optional event/alias dependency 9 | "../event/alias" 10 | ], function( jQuery ) { 11 | 12 | // Keep a copy of the old load method 13 | var _load = jQuery.fn.load; 14 | 15 | /** 16 | * Load a url into a page 17 | */ 18 | jQuery.fn.load = function( url, params, callback ) { 19 | if ( typeof url !== "string" && _load ) { 20 | return _load.apply( this, arguments ); 21 | } 22 | 23 | var selector, type, response, 24 | self = this, 25 | off = url.indexOf(" "); 26 | 27 | if ( off >= 0 ) { 28 | selector = jQuery.trim( url.slice( off ) ); 29 | url = url.slice( 0, off ); 30 | } 31 | 32 | // If it's a function 33 | if ( jQuery.isFunction( params ) ) { 34 | 35 | // We assume that it's the callback 36 | callback = params; 37 | params = undefined; 38 | 39 | // Otherwise, build a param string 40 | } else if ( params && typeof params === "object" ) { 41 | type = "POST"; 42 | } 43 | 44 | // If we have elements to modify, make the request 45 | if ( self.length > 0 ) { 46 | jQuery.ajax({ 47 | url: url, 48 | 49 | // if "type" variable is undefined, then "GET" method will be used 50 | type: type, 51 | dataType: "html", 52 | data: params 53 | }).done(function( responseText ) { 54 | 55 | // Save response for use in complete callback 56 | response = arguments; 57 | 58 | self.html( selector ? 59 | 60 | // If a selector was specified, locate the right elements in a dummy div 61 | // Exclude scripts to avoid IE 'Permission Denied' errors 62 | jQuery("
").append( jQuery.parseHTML( responseText ) ).find( selector ) : 63 | 64 | // Otherwise use the full result 65 | responseText ); 66 | 67 | }).complete( callback && function( jqXHR, status ) { 68 | self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] ); 69 | }); 70 | } 71 | 72 | return this; 73 | }; 74 | 75 | }); 76 | -------------------------------------------------------------------------------- /demo-app/bower_components/jquery/src/ajax/parseJSON.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core" 3 | ], function( jQuery ) { 4 | 5 | // Support: Android 2.3 6 | // Workaround failure to string-cast null input 7 | jQuery.parseJSON = function( data ) { 8 | return JSON.parse( data + "" ); 9 | }; 10 | 11 | return jQuery.parseJSON; 12 | 13 | }); 14 | -------------------------------------------------------------------------------- /demo-app/bower_components/jquery/src/ajax/parseXML.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core" 3 | ], function( jQuery ) { 4 | 5 | // Cross-browser xml parsing 6 | jQuery.parseXML = function( data ) { 7 | var xml, tmp; 8 | if ( !data || typeof data !== "string" ) { 9 | return null; 10 | } 11 | 12 | // Support: IE9 13 | try { 14 | tmp = new DOMParser(); 15 | xml = tmp.parseFromString( data, "text/xml" ); 16 | } catch ( e ) { 17 | xml = undefined; 18 | } 19 | 20 | if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) { 21 | jQuery.error( "Invalid XML: " + data ); 22 | } 23 | return xml; 24 | }; 25 | 26 | return jQuery.parseXML; 27 | 28 | }); 29 | -------------------------------------------------------------------------------- /demo-app/bower_components/jquery/src/ajax/script.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "../core", 3 | "../ajax" 4 | ], function( jQuery ) { 5 | 6 | // Install script dataType 7 | jQuery.ajaxSetup({ 8 | accepts: { 9 | script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" 10 | }, 11 | contents: { 12 | script: /(?:java|ecma)script/ 13 | }, 14 | converters: { 15 | "text script": function( text ) { 16 | jQuery.globalEval( text ); 17 | return text; 18 | } 19 | } 20 | }); 21 | 22 | // Handle cache's special case and crossDomain 23 | jQuery.ajaxPrefilter( "script", function( s ) { 24 | if ( s.cache === undefined ) { 25 | s.cache = false; 26 | } 27 | if ( s.crossDomain ) { 28 | s.type = "GET"; 29 | } 30 | }); 31 | 32 | // Bind script tag hack transport 33 | jQuery.ajaxTransport( "script", function( s ) { 34 | // This transport only deals with cross domain requests 35 | if ( s.crossDomain ) { 36 | var script, callback; 37 | return { 38 | send: function( _, complete ) { 39 | script = jQuery(" 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /demo-app/ng-repeat/bind-once.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
Contacts
{{::$index}} 9 | {{::contact.name}} 10 | {{::contact.company}}{{::contact.email}}{{::contact.age}}{{::contact.eyeColor}}{{::contact.gender}}{{::contact.phone}}{{::contact.address}}{{::contact.registered}}{{::contact.latitude}}{{::contact.longitude}}{{::contact.favoriteFruit}}
-------------------------------------------------------------------------------- /demo-app/ng-repeat/class-expression.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Random 5 | 6 |
7 | 8 |
9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
Contacts
18 |
33 | 34 | 35 |
36 | -------------------------------------------------------------------------------- /demo-app/ng-repeat/complex-expressions.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
Contacts
9 |
42 | 43 | 44 |
45 | -------------------------------------------------------------------------------- /demo-app/ng-repeat/direct.html: -------------------------------------------------------------------------------- 1 |
-------------------------------------------------------------------------------- /demo-app/ng-repeat/expression-bind.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |
Contacts
{{$index + 1}} 10 | {{contact.name}} 11 | {{contact.company}}{{contact.email}}{{contact.age}}{{contact.eyeColor}}{{contact.gender}}{{contact.phone}}{{contact.address}}{{contact.registered}}{{contact.latitude}}{{contact.longitude}}{{contact.favoriteFruit}}
26 | 27 | 28 |
29 | -------------------------------------------------------------------------------- /demo-app/ng-repeat/ng-bind.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
Contacts
8 |
-------------------------------------------------------------------------------- /demo-app/ng-repeat/ng-class.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Random 5 | 6 |
7 | 8 |
9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
Contacts
18 |
33 | 34 | 35 |
36 | -------------------------------------------------------------------------------- /demo-app/ng-repeat/ng-style.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Random 5 | 6 |
7 | 8 |
9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
Contacts
18 |
33 | 34 | 35 |
36 | -------------------------------------------------------------------------------- /demo-app/ng-repeat/repeat-ctrl.js: -------------------------------------------------------------------------------- 1 | angular.module('NgPerf.controllers', []). 2 | 3 | controller('repeatController', ['$scope', '$http', '$log', '$compile', '$routeParams', function($scope, $http, $log, $compile, $routeParams) { 4 | var direct = false, preBind = false; 5 | $scope.contacts = []; 6 | $scope.random = function () { 7 | $scope.randomNumber = Math.round(Math.random()*100); 8 | } 9 | $scope.flipColor = function () { 10 | $scope.negative = !$scope.negative; 11 | $scope.color = $scope.negative? "red":"green"; 12 | } 13 | $scope.myFunction = function () { 14 | return '1234'; 15 | } 16 | $scope.fetchData = function () { 17 | if (preBind) { 18 | $.get('ng-repeat/ng-repeat-data-1000.json', function (data) { 19 | //angular.element("#myRemovableTable").detach(); 20 | angular.element("#directHTML").empty(); 21 | $scope.preloadedContacts = data;//.splice(0,3); 22 | $.get('../ng-repeat/repeat-template.html', function (data) { 23 | var orig = jQuery.fn.data; 24 | var el = angular.element(data); 25 | el.attr('id', 'myRemovableTable'); 26 | var linkFn = $compile(el); 27 | linkFn($scope); 28 | $scope.$digest(); 29 | angular.element("#directHTML").append(el); 30 | }); 31 | }); 32 | } else { 33 | 34 | $http({method: 'GET', url: 'ng-repeat/ng-repeat-data-1000.json'}). 35 | success(function(data, status, headers, config) { 36 | 37 | if (!$routeParams.direct) { 38 | 39 | $scope.contacts = data; 40 | 41 | } else { 42 | 43 | var htmlStr = '', 44 | fields = ['name', 'company', 'email', 'age', 'eyeColor', 'gender', 'phone', 'address', 'registered', 'latitude', 'longitude', 'favoriteFruit']; 45 | for (var i = 0; i < data.length; i ++) { 46 | var contact = data[i]; 47 | htmlStr += ''; 48 | for(var j = 0; j < fields.length; j++ ) { 49 | htmlStr += '' 50 | } 51 | htmlStr += ''; 52 | } 53 | htmlStr += '
' + contact[fields[j]] + '
'; 54 | //$("#directHTML").innerHTML = "HELLO"; 55 | angular.element("#directHTML").html(htmlStr); 56 | //$scope.tableHTML = htmlStr; 57 | 58 | } 59 | }). 60 | error(function(data, status, headers, config) { 61 | $log.error(data); 62 | }); 63 | } 64 | 65 | }; 66 | $scope.fetchData(); 67 | $scope.changeData = function() { 68 | $scope.contacts[0] && ($scope.contacts[0].name = Math.round(Math.random()*100)); 69 | } 70 | }]); 71 | 72 | angular.module('NgPerf.controllers'). 73 | controller('randomController', ['$scope', '$http', '$log', '$compile', function($scope, $http, $log, $compile) { 74 | $scope.randomNumber = '123'; 75 | $scope.generateRandom = function() { 76 | $scope.randomNumber = Math.floor(Math.random()*100); 77 | // event.preventDefault(); //uncomment to suppress digest altogether 78 | } 79 | }]); -------------------------------------------------------------------------------- /demo-app/ng-repeat/repeat-template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
{{$index + 1}} 5 | {{contact.name}} 6 | {{contact.company}}{{contact.email}}{{contact.age}}{{contact.eyeColor}}{{contact.gender}}{{contact.phone}}{{contact.address}}{{contact.registered}}{{contact.latitude}}{{contact.longitude}}{{contact.favoriteFruit}}
-------------------------------------------------------------------------------- /demo-app/ng-repeat/repeat-view.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Random Local 5 | 6 | 7 |
8 | 9 |
10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 |
Contacts
19 |
52 | 53 | 54 |
55 | -------------------------------------------------------------------------------- /lib/ng-perf-patches.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * License: MIT 4 | * @Description: Shameless hacks to workaround angular performance bottlenecks 5 | * 6 | */ 7 | //Bypass .data calls with argument $binding improves ng-bind and {{}} expression binding performance 8 | //Applies to 1.2 only 9 | if (jQuery) { 10 | var originalFn = $.fn.data; 11 | $.fn.data = function() { 12 | if (arguments[0] !== '$binding') 13 | return originalFn.apply(this, arguments); 14 | } 15 | } -------------------------------------------------------------------------------- /lib/ngpLocalEventDirs.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * 5 | * License: MIT 6 | * @Description: ngp-local-* directives are very similar to ng-* event directives such as ng-click etc. except that 7 | * it calls digest on the immediate scope instead of $rootScope.$digest(). Additionally calling preventDefault on the event 8 | * stops digest calls. 9 | * 10 | */ 11 | 12 | angular.module('ngPerf.directives', []); 13 | angular.forEach( 14 | 'click dblclick mousedown mouseup mouseover mouseout mousemove mouseenter mouseleave keydown keyup keypress submit focus blur copy cut paste'.split(' '), 15 | function(eventName) { 16 | var directiveName = 'ngpLocal' + eventName.charAt(0).toUpperCase() + eventName.substr(1); 17 | angular.module('ngPerf.directives').directive(directiveName, ['$parse', function($parse) { 18 | return { 19 | restrict: 'A', 20 | compile: function($element, attr) { 21 | var fn = $parse(attr[directiveName]); 22 | return function localEventHandler(scope, element) { 23 | element.on(eventName, function(event) { 24 | var callback = function() { 25 | fn(scope, {$event:event}); 26 | }; 27 | scope.$eval(callback); 28 | if (!event.isDefaultPrevented()) { 29 | scope.$digest(); 30 | } 31 | }); 32 | }; 33 | } 34 | }; 35 | }]); 36 | } 37 | ); 38 | --------------------------------------------------------------------------------