Note: If you're viewing this page via a file:// URL, the "next" and "previous" Glyphicon buttons on the left and right might not load/display properly due to web browser security rules.
Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.
Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.
Donec sed odio dui. Etiam porta sem malesuada magna mollis euismod. Nullam id dolor id nibh ultricies vehicula ut id elit. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Praesent commodo cursus magna.
Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh.
Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.
Donec ullamcorper nulla non metus auctor fringilla. Vestibulum id ligula porta felis euismod semper. Praesent commodo cursus magna, vel scelerisque nisl consectetur. Fusce dapibus, tellus ac cursus commodo.
+
+
+
+
+
+
+
+
+
+
+
Oh yeah, it's that good. See for yourself.
+
Donec ullamcorper nulla non metus auctor fringilla. Vestibulum id ligula porta felis euismod semper. Praesent commodo cursus magna, vel scelerisque nisl consectetur. Fusce dapibus, tellus ac cursus commodo.
+
+
+
+
+
+
+
+
+
+
+
And lastly, this one. Checkmate.
+
Donec ullamcorper nulla non metus auctor fringilla. Vestibulum id ligula porta felis euismod semper. Praesent commodo cursus magna, vel scelerisque nisl consectetur. Fusce dapibus, tellus ac cursus commodo.
This is a template showcasing the optional theme stylesheet included in Bootstrap. Use it as a starting point to create something more unique by building on or modifying it.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed diam eget risus varius blandit sit amet non magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Cras mattis consectetur purus sit amet fermentum. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Aenean lacinia bibendum nulla sed consectetur.
diff --git a/docs/content/guide/production.ngdoc b/docs/content/guide/production.ngdoc
index 52d088122ca3..bf9e1369c70c 100644
--- a/docs/content/guide/production.ngdoc
+++ b/docs/content/guide/production.ngdoc
@@ -73,3 +73,37 @@ angular.bootstrap(document, ['myApp'], {
For more information, see the
{@link di#using-strict-dependency-injection DI Guide}.
+
+
+## Disable comment and css class directives
+
+By default AngularJS compiles and executes all directives inside comments and element classes.
+In order to perform this task, angular compiler must look for directives by:
+
+- Parse all your application element classes.
+
+- Parse all your application html comments.
+
+Nowadays most of the Angular projects are using only element and attribute directives,
+and in such projects there is no need to compile comments and classes.
+
+If you are sure that your project only uses element and attribute directives,
+and you are not using any 3rd part library that uses
+directives inside element classes or html comments,
+you can disable the compilation of directives on element classes and comments
+for the whole application.
+This results in a compilation performance gain,
+as the compiler does not have to check comments and element classes looking for directives.
+
+To disable comment and css class directives use the `$compileProvider`:
+
+```
+$compileProvider.commentDirectivesEnabled(false);
+$compileProvider.cssClassDirectivesEnabled(false);
+```
+
+For more see the docs pages on
+{@link ng.$compileProvider#commentDirectivesEnabled `$compileProvider.commentDirectivesEnabled`}
+and
+{@link ng.$compileProvider#cssClassDirectivesEnabled `$compileProvider.cssClassDirectivesEnabled`}.
+
diff --git a/src/ng/compile.js b/src/ng/compile.js
index 68efce04f11f..7fb803ae91fd 100644
--- a/src/ng/compile.js
+++ b/src/ng/compile.js
@@ -1387,6 +1387,63 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
return TTL;
};
+ var commentDirectivesEnabledConfig = true;
+ /**
+ * @ngdoc method
+ * @name $compileProvider#commentDirectivesEnabled
+ * @description
+ *
+ * It indicates to the compiler
+ * whether or not directives on comments should be compiled.
+ * Defaults to `true`.
+ *
+ * Calling this function with false disables the compilation of directives
+ * on comments for the whole application.
+ * This results in a compilation performance gain,
+ * as the compiler doesn't have to check comments when looking for directives.
+ * This should however only be used if you are sure that no comment directives are used in
+ * the application (including any 3rd party directives).
+ *
+ * @param {boolean} enabled `false` if the compiler may ignore directives on comments
+ * @returns {boolean|object} the current value (or `this` if called as a setter for chaining)
+ */
+ this.commentDirectivesEnabled = function(value) {
+ if (arguments.length) {
+ commentDirectivesEnabledConfig = value;
+ return this;
+ }
+ return commentDirectivesEnabledConfig;
+ };
+
+
+ var cssClassDirectivesEnabledConfig = true;
+ /**
+ * @ngdoc method
+ * @name $compileProvider#cssClassDirectivesEnabled
+ * @description
+ *
+ * It indicates to the compiler
+ * whether or not directives on element classes should be compiled.
+ * Defaults to `true`.
+ *
+ * Calling this function with false disables the compilation of directives
+ * on element classes for the whole application.
+ * This results in a compilation performance gain,
+ * as the compiler doesn't have to check element classes when looking for directives.
+ * This should however only be used if you are sure that no class directives are used in
+ * the application (including any 3rd party directives).
+ *
+ * @param {boolean} enabled `false` if the compiler may ignore directives on element classes
+ * @returns {boolean|object} the current value (or `this` if called as a setter for chaining)
+ */
+ this.cssClassDirectivesEnabled = function(value) {
+ if (arguments.length) {
+ cssClassDirectivesEnabledConfig = value;
+ return this;
+ }
+ return cssClassDirectivesEnabledConfig;
+ };
+
this.$get = [
'$injector', '$interpolate', '$exceptionHandler', '$templateRequest', '$parse',
'$controller', '$rootScope', '$sce', '$animate', '$$sanitizeUri',
@@ -1397,6 +1454,9 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
var specialAttrHolder = window.document.createElement('div');
+ var commentDirectivesEnabled = commentDirectivesEnabledConfig;
+ var cssClassDirectivesEnabled = cssClassDirectivesEnabledConfig;
+
var onChangesTtl = TTL;
// The onChanges hooks should all be run together in a single digest
@@ -2043,6 +2103,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
}
// use class as directive
+ if (!cssClassDirectivesEnabled) break;
className = node.className;
if (isObject(className)) {
// Maybe SVGAnimatedString
@@ -2069,6 +2130,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
addTextInterpolateDirective(directives, node.nodeValue);
break;
case NODE_TYPE_COMMENT: /* Comment */
+ if (!commentDirectivesEnabled) break;
collectCommentDirectives(node, directives, attrs, maxPriority, ignoreDirective);
break;
}
diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js
index bb757575eab8..568ffcd1d369 100755
--- a/test/ng/compileSpec.js
+++ b/test/ng/compileSpec.js
@@ -3363,6 +3363,146 @@ describe('$compile', function() {
});
});
+ describe('collector', function() {
+
+ var collected;
+ beforeEach(module(function($compileProvider) {
+ collected = false;
+ $compileProvider.directive('testCollect', function() {
+ return {
+ restrict: 'EACM',
+ link: function() {
+ collected = true;
+ }
+ };
+ });
+ }));
+
+ it('should collect comment directives by default', inject(function() {
+ var html = '';
+ element = $compile('