diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js index c85ce3a22..880d9c7d3 100644 --- a/chrome/content/zotero/browser.js +++ b/chrome/content/zotero/browser.js @@ -103,10 +103,6 @@ var Zotero_Browser = new function() { Zotero_Browser.browserData = new Object(); Zotero_Browser._scrapePopupShowing = false; - Zotero.Proxies.init(); - Zotero.Ingester.MIMEHandler.init(); - Zotero.Cite.MIMEHandler.init(); - Zotero.Translators.init(); window.addEventListener("load", function(e) { Zotero_Browser.chromeLoad(e) }, false); diff --git a/chrome/content/zotero/xpcom/translate.js b/chrome/content/zotero/xpcom/translate.js index 2e8b82336..7d50f4631 100644 --- a/chrome/content/zotero/xpcom/translate.js +++ b/chrome/content/zotero/xpcom/translate.js @@ -37,17 +37,21 @@ const BOMs = { * @namespace */ Zotero.Translators = new function() { - var _cache = {"import":[], "export":[], "web":[], "search":[]}; - var _translators = {}; + var _cache, _translators; var _initialized = false; /** * Initializes translator cache, loading all relevant translators into memory */ this.init = function() { - if(_initialized) return; _initialized = true; + var start = (new Date()).getTime() + + _cache = {"import":[], "export":[], "web":[], "search":[]}; + _translators = {}; + + var i = 0; var contents = Zotero.getTranslatorsDirectory().directoryEntries; while(contents.hasMoreElements()) { var file = contents.getNext().QueryInterface(Components.interfaces.nsIFile); @@ -71,13 +75,17 @@ Zotero.Translators = new function() { } } } + i++; } + + Zotero.debug("Cached "+i+" translators in "+((new Date()).getTime() - start)+" ms"); } /** * Gets the translator that corresponds to a given ID */ this.getTranslatorById = function(id) { + if(!_initialized) this.init(); return _translators[id] ? _translators[id] : false; } @@ -85,6 +93,7 @@ Zotero.Translators = new function() { * Gets all translators for a specific type of translation */ this.getTranslatorsByType = function(type) { + if(!_initialized) this.init(); return _cache[type].slice(0); } } diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index d01dd7bc2..6ecf4064d 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -97,6 +97,8 @@ var Zotero = new function(){ return false; } + var start = (new Date()).getTime() + // Register shutdown handler to call Zotero.shutdown() /* var observerService = Components.classes["@mozilla.org/observer-service;1"] @@ -273,7 +275,12 @@ var Zotero = new function(){ Zotero.Sync.Runner.init(); Zotero.Sync.Storage.init(); + Zotero.Proxies.init(); + Zotero.Ingester.MIMEHandler.init(); + Zotero.Cite.MIMEHandler.init(); + this.initialized = true; + Zotero.debug("Initialized in "+((new Date()).getTime() - start)+" ms"); return true; }