Reputation: 4274
As you know it's possible to use angularJS directives as attributes with different prefixes:
data-
, x-
, _
, :
. and also it's possible to use a directive as attribute or a distinct element and comment.
do the prefixes or the type affect the speed of HTML compilation? if so, which is the fastest?
Upvotes: 4
Views: 92
Reputation: 67296
In the source for compile.js
there is a regex:
var PREFIX_REGEXP = /^((?:x|data)[\:\-_])/i;
The name is always normalized with this function:
function directiveNormalize(name) {
return camelCase(name.replace(PREFIX_REGEXP, ''));
}
And the directiveNormalize
function is used for all compile operations that use the name of the attribute.
So, it should not make any difference from a compile performance perspective.
Upvotes: 3