diff --git a/index.html b/index.html
index adad7ef..d1dd0ed 100644
--- a/index.html
+++ b/index.html
@@ -19,7 +19,6 @@
-
diff --git a/js/glowingbear.js b/js/glowingbear.js
index 526c46f..2ccf3f3 100644
--- a/js/glowingbear.js
+++ b/js/glowingbear.js
@@ -377,6 +377,22 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
}
});
+ // To reduce loading times for users who don't want twemoji,
+ // load it only if the setting is enabled.
+ // This also fires when the page is loaded.
+ settings.addCallback('enableJSEmoji', function(enabled) {
+ if (enabled && !$rootScope.twemoji_init) {
+ // Load twemoji only once
+ $rootScope.twemoji_init = true;
+ (function() {
+ var script = document.createElement("script");
+ script.type = "text/javascript";
+ script.src = "//twemoji.maxcdn.com/twemoji.min.js";
+ document.getElementsByTagName("head")[0].appendChild(script);
+ })();
+ }
+ });
+
// Update font family when changed
settings.addCallback('fontfamily', function(fontfamily) {
utils.changeClassStyle('favorite-font', 'fontFamily', fontfamily);