-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a bind-translate directive #72
Comments
This is interesting. How does |
Looking at the source of In theory this means there shouldn't be a difference. Do you have an example of this speed difference? |
The final dirty checking code is the same, however the differences are:
So the biggest performance difference comes from using filters vs. using directives. |
The page you linked to says nothing about performance. Seems like your issue is based on this, which also doesn't list any verifiable numbers (so it's worthless). As a general principle, I don't accept any arguments about performance unless they're backed up by numbers (which can be validated). I can see (intuitively) where the difference comes from, but unless we have measurable numbers, it's just feelings and speculation. It's not worth adding extra functionality if the difference is negligible. You said you did some tests and measurements, can you share them? |
Also, not that you don't have to use filters, you can just do this: <span translate>Hello</span> |
The numbers I got were from Batarang, but since it's not a reliable source (it might just be the difference of filters vs directives, or some random stuff). |
Ok, before discuss the performance details, Given the following use cases:
<button translate>
{{ someText }}
</button>
<button ng-bind="someText" translate>
</button>
<button>
{{ someText | translate }}
</button>
<button ng-bind="someText | translate">
</button>
<button translate="someText">
</button> Note: One wouldn't really expect case 1) to work, but 2) can be expected. If 2) or 5) are implemented, it will solve the biggest performance (and usability) factor. |
+1 for Nice project BTW! |
@gunta, interested to know if you're still considering adding some like |
Please take a look at #141. I have no problem supporting |
Hi!
I'm creating a big application with lot's of translated data where performance is suffering, so while debugging the bottlenecks with Batarang I found that it would be required to have a bind-translated directive.
Why?
Visibility:
While AngularJS is bootstrapping, the user might see your placed brackets in the html. This can be handled with
ng-cloak
. But for me this is a workaround, that I don't need to use, if I useng-bind
.Performance:
The
{{}}
is much slower.This
ng-bind
is a directive and will place a watcher on the passed variable. So theng-bind
will only apply, when the passed value does actually change.The brackets on the other hand will be dirty checked and refreshed in every
$digest
, even if it's not necessary.In my experiments, changing from
{{}}
to strictng-bind
saves around 20~40% in every scope.$digest.Suggestion:
Use a directive instead of the brackets annotation.
Instead of
use↓
For example
angular-translate
does this with the directive ng-translate.The text was updated successfully, but these errors were encountered: