Skip to content

Commit

Permalink
Boost Angular performance by disable debug and add ng-strict-di in de…
Browse files Browse the repository at this point in the history
…mo app
  • Loading branch information
jeromemacias committed May 12, 2015
1 parent 60fd212 commit 39a4d49
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ module.exports = function (grunt) {
},
javascripts: {
files: ['src/javascripts/ng-admin.js', 'src/javascripts/ng-admin/**/**/*.js', 'src/javascripts/ng-admin/**/**/*.html'],
tasks: ['ngconfig', 'requirejs:dev', 'copy:js_dev', 'copy:es6_dev', 'copy:es6_devmap'],
tasks: ['ngconfig', 'requirejs:dev', 'ngAnnotate', 'copy:js_dev', 'copy:es6_dev', 'copy:es6_devmap'],
options: {
atBegin: true,
livereload: true
Expand Down Expand Up @@ -250,7 +250,7 @@ module.exports = function (grunt) {

grunt.registerTask('test:local', ['mochaTest', 'karma', 'build:dev', 'copy_build:dev', 'test:local:e2e']);
grunt.registerTask('test:local:e2e', ['json_server', 'connect', 'protractor']);
grunt.registerTask('build:dev', ['ngconfig', 'requirejs:dev', 'compass:dev', 'concat:css']);
grunt.registerTask('build:dev', ['ngconfig', 'requirejs:dev', 'ngAnnotate', 'compass:dev', 'concat:css']);
grunt.registerTask('copy_build:dev', ['copy:es6_dev', 'copy:es6_devmap', 'copy:js_dev', 'copy:angular', 'copy:css_dev', 'copy:fonts_dev', 'clean']);

// register default task
Expand Down
12 changes: 6 additions & 6 deletions examples/blog/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

var app = angular.module('myApp', ['ng-admin']);

app.config(function (NgAdminConfigurationProvider, RestangularProvider) {
app.config(['NgAdminConfigurationProvider', 'RestangularProvider', function (NgAdminConfigurationProvider, RestangularProvider) {
var nga = NgAdminConfigurationProvider;

function truncate(value) {
Expand Down Expand Up @@ -276,7 +276,7 @@
);

nga.configure(admin);
});
}]);

app.directive('postLink', ['$location', function ($location) {
return {
Expand Down Expand Up @@ -333,7 +333,7 @@
'<div class="col-lg-5"><a class="btn btn-default" ng-click="controller.sendEmail()">Send</a></div>' +
'</div>';

app.config(function ($stateProvider) {
app.config(['$stateProvider', function ($stateProvider) {
$stateProvider.state('send-post', {
parent: 'main',
url: '/sendPost/:id',
Expand All @@ -342,7 +342,7 @@
controllerAs: 'controller',
template: sendPostControllerTemplate
});
});
}]);

// custom page with menu item
var customPageTemplate = '<div class="row"><div class="col-lg-12">' +
Expand All @@ -352,12 +352,12 @@
'<p class="lead">You can add custom pages, too</p>' +
'</div>' +
'</div></div>';
app.config(function ($stateProvider) {
app.config(['$stateProvider', function ($stateProvider) {
$stateProvider.state('stats', {
parent: 'main',
url: '/stats',
template: customPageTemplate
});
});
}]);

}());
2 changes: 1 addition & 1 deletion examples/blog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<script src="build/ng-admin.js" type="text/javascript"></script>
<script src="config.js" type="text/javascript"></script>
</head>
<body ng-app="myApp">
<body ng-app="myApp" ng-strict-di>
<div ui-view></div>
</body>
</html>
5 changes: 3 additions & 2 deletions src/javascripts/ng-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ define(function (require) {
factory.constant('AdminDescription', new AdminDescription());

var ngadmin = angular.module('ng-admin', ['main', 'crud', 'AdminDescriptionModule']);
ngadmin.config(function(NgAdminConfigurationProvider, AdminDescription) {
ngadmin.config(['NgAdminConfigurationProvider', 'AdminDescription', '$compileProvider', function(NgAdminConfigurationProvider, AdminDescription, $compileProvider) {
$compileProvider.debugInfoEnabled(false);
NgAdminConfigurationProvider.setAdminDescription(AdminDescription);
});
}]);
});
4 changes: 4 additions & 0 deletions src/javascripts/test/protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ exports.config = {
showColors: true,
includeStackTrace: true,
defaultTimeoutInterval: 360000
},

onPrepare: function () {
browser.executeScript('window.name = "NG_ENABLE_DEBUG_INFO"');
}
};

0 comments on commit 39a4d49

Please sign in to comment.