-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Performance issue with tooltips #1450
Comments
I guess this is something we should look into, yes. Having said this an AngularJS application with several thousands bindings will hit a limit somewhere else, I guess.... |
As a first workaround, here is how I bundled the original tooltip into another directive to get this "late" evaluation: reportResultsApp.directive(
"rrTooltip", [ "$compile", function($compile) {
return {
restrict: 'A',
scope: {
content: '@rrTooltip'
},
compile: function($element, attr) {
return function(scope, element, attr) {
element.on("mouseenter", function(event) {
// Only now, we will build the new element
// with the tooltip if it doesn't exist (or
// doesn't match the tooltip)
var inside = element.children();
if (!inside.length) {
inside = angular.element("<span>");
}
if (inside.attr("tooltip") === scope.content) return;
inside.attr("tooltip", scope.content);
// And insert it
var compiled = $compile(inside);
var linked = compiled(scope);
element.empty();
element.append(linked);
});
}
}
}
}
]); This gives me about the same performance as with no tooltip. However, my bindings are not updated, so maybe it would crumble when this happens. |
I haven't tested this thoroughly so I might be wrong but my feeling is that it's actually the linking that's causing the slowdown. Right now both compilation and linking of the template is done in the link function of the $tooltip.
This will also solve #1191 and should speed things up considerably as none of the watchers on the template will actually be on the scope. |
Attempts to fix angular-ui#1450
@vincentbernat Still a work-in-progress but you can check out https://github.com/chrisirhc/angular-ui-bootstrap/tree/feature/tooltip-scope-rework to see if that resolves the performance issue you're running into. |
@chrisirhc I tried but I get an |
@vincentbernat Try running |
@chrisirhc This worked. Do you think I should file a bug/PR for this (task Otherwise, performance is pretty good! Currently, the tooltip disappear after a second without the mouse leaving the element. |
Attempts to fix angular-ui#1450
Attempts to fix angular-ui#1450
@vincentbernat That's good. The positions are broken. I'll fix that in a bit. Regarding the html2js task, I think it's a known issue but feel free to file it or submit a pull request for that. |
- Calling $digest is enough as we only need to digest the watchers in this scope and its children. No need to call $apply. - No need to test for cached reference when tooltip isn't visible as the tooltip has no scope. Attempts to fix angular-ui#1450
- Calling $digest is enough as we only need to digest the watchers in this scope and its children. No need to call $apply. - No need to test for cached reference when tooltip isn't visible as the tooltip has no scope. Fixes angular-ui#1450 and angular-ui#1191
The |
@vincentbernat , I've updated #1455 and fixed the position, tooltips should behave as expected now. Could you try it out and let me know what you think? |
@chrisirhc , it works fine for me. Performance is good and I didn't trigger any issue. Thanks! |
- Calling $digest is enough as we only need to digest the watchers in this scope and its children. No need to call $apply. - Set invokeApply to false on $timeout for popUpDelay - No need to test for cached reference when tooltip isn't visible as the tooltip has no scope. Fixes angular-ui#1450 and angular-ui#1191
I've pushed 79d2627 by accident, had to revert it... |
- Calling $digest is enough as we only need to digest the watchers in this scope and its children. No need to call $apply. - Set invokeApply to false on $timeout for popUpDelay - No need to test for cached reference when tooltip isn't visible as the tooltip has no scope. Fixes angular-ui#1450 and angular-ui#1191
I am still seeing performance issues with tooltips. I have about 500 of them on my page. And they cause the page to become unresponsive for several seconds on load. Sometimes it even causes my Firefox browser to show the unresponsive script prompt. Although everything works fine after that initial wait. |
I am using a lot of tooltips. Something like several thousands. Since the template for the tooltip is compiled for each of them, the page is quite slow to render and spent a lot of time in parsing HTML. Would it be possible to compute tooltip template later in the life-cycle? For example, only when the tooltip has to be displayed.
Thanks.
The text was updated successfully, but these errors were encountered: