我自己创建了一个Firefox附加组件,它们会慢慢打开,但问题是通用的。
检查加载速度有多慢: https://addons.mozilla.org/pl/firefox/addon/best-theme-like-google-materia/
每个for
数组的 browserWindows
循环:
var { viewFor } = require("sdk/view/core");
var windows = require("sdk/windows");
var browserWindows = windows.browserWindows;
for (let browserWindow of browserWindows) {
let chromeWindow = viewFor(browserWindow);
module.enable(chromeWindow);
}
然后是新打开的窗口:
browserWindows.on('open', function(browserWindow) {
var chromeWindow = viewFor(browserWindow);
module.enable(chromeWindow);
});
并禁用每个浏览器窗口 - 同一阵列上的for
循环:
var browserWindows = windows.browserWindows;
for (let browserWindow of browserWindows) {
let chromeWindow = viewFor(browserWindow);
module.disable(chromeWindow);
}
在我看来,在这些函数中,windows的加载器是个问题。 因为他在转动时会添加不应粘的东西,例如:
var style = require("sdk/stylesheet/utils");
var self = require("sdk/self");
function enable (window) {
style.loadSheet(window, self.data.url("toolbars/tabs.css"), "author");
style.loadSheet(window, self.data.url("toolbars/navigator.css"), "author");
style.loadSheet(window, self.data.url("toolbars/other-toolbars.css"), "author");
}
function disable (window) {
style.removeSheet(window, self.data.url("toolbars/tabs.css"), "author");
style.removeSheet(window, self.data.url("toolbars/navigator.css"), "author");
style.removeSheet(window, self.data.url("toolbars/other-toolbars.css"), "author");
}
如何更有效地做到这一点,而不是让收费变得浑浊?