Set favicon from our generated images rather than using Notificon

We've been noticing a long delay between switching to a window with unread
messages and the time that those messages actually appear.  This got much worse
around the time we added Notificon.

Our hypothesis (supported by some testing) is that the work done by Notificon
in creating a <canvas>, drawing into it, serializing it to PNG, etc. is using
up some quota of background operations that would be better spent rendering
messages.

Switching to precomputed images should mitigate this problem.

Resolves #896.

May resolve #882 to our satisfaction.

(imported from commit a2d98a163486bdd35fdfb5351f96c5529ba5c7e9)
This commit is contained in:
Keegan McAllister
2013-02-15 15:31:38 -05:00
parent c0054f6335
commit ddcf2cb86e
2 changed files with 30 additions and 2 deletions

View File

@@ -7,11 +7,22 @@ exports.random_int = function random_int(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
};
var favicon_selector = 'link[rel="shortcut icon"]';
// We need to reset the favicon after changing the
// window.location.hash or Firefox will drop the favicon. See
// https://bugzilla.mozilla.org/show_bug.cgi?id=519028
exports.reset_favicon = function () {
$('link[rel="shortcut icon"]').detach().appendTo('head');
$(favicon_selector).detach().appendTo('head');
};
exports.set_favicon = function (url) {
// I'm not sure whether setting the href attr on the existing
// node would be sufficient. Notificon recreates the node.
$(favicon_selector).remove();
$('head').append($('<link>')
.attr('rel', 'shortcut icon')
.attr('href', url));
};
exports.make_loading_indicator = function (container, text) {