Bladeren bron

Move some functions outside of the `initialize` closure

JC Brand 6 jaren geleden
bovenliggende
commit
d3a684a57d
3 gewijzigde bestanden met toevoegingen van 294 en 277 verwijderingen
  1. 149 142
      dist/converse.js
  2. 1 1
      spec/converse.js
  3. 144 134
      src/headless/converse-core.js

+ 149 - 142
dist/converse.js

@@ -62522,7 +62522,11 @@ _lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.templateSettings = {
   'imports': {
     '_': _lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a
   }
-};
+}; // Setting wait to 59 instead of 60 to avoid timing conflicts with the
+// webserver, which is often also set to 60 and might therefore sometimes
+// return a 504 error page instead of passing through to the BOSH proxy.
+
+const BOSH_WAIT = 59;
 /**
  * A private, closured object containing the private api (via `_converse.api`)
  * as well as private methods and internal data-structures.
@@ -62534,18 +62538,16 @@ const _converse = {
   'templates': {},
   'promises': {}
 };
+_converse.VERSION_NAME = "v4.0.5";
 
-_lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.extend(_converse, Backbone.Events);
+_lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.extend(_converse, Backbone.Events); // Make converse pluggable
 
-_converse.VERSION_NAME = "v4.0.5"; // Core plugins are whitelisted automatically
-
-_converse.core_plugins = ['converse-chatboxes', 'converse-core', 'converse-disco', 'converse-mam', 'converse-muc', 'converse-ping', 'converse-roster', 'converse-vcard']; // Setting wait to 59 instead of 60 to avoid timing conflicts with the
-// webserver, which is often also set to 60 and might therefore sometimes
-// return a 504 error page instead of passing through to the BOSH proxy.
 
-const BOSH_WAIT = 59; // Make converse pluggable
+pluggable_js_dist_pluggable__WEBPACK_IMPORTED_MODULE_8___default.a.enable(_converse, '_converse', 'pluggable'); // Core plugins are whitelisted automatically
+// These are just the @converse/headless plugins, for the full converse,
+// the other plugins are whitelisted in src/converse.js
 
-pluggable_js_dist_pluggable__WEBPACK_IMPORTED_MODULE_8___default.a.enable(_converse, '_converse', 'pluggable');
+_converse.core_plugins = ['converse-chatboxes', 'converse-core', 'converse-disco', 'converse-mam', 'converse-muc', 'converse-ping', 'converse-roster', 'converse-vcard'];
 _converse.keycodes = {
   TAB: 9,
   ENTER: 13,
@@ -62769,38 +62771,155 @@ _converse.isSingleton = function () {
 
 _converse.router = new Backbone.Router();
 
-_converse.initialize = function (settings, callback) {
-  settings = !_lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.isUndefined(settings) ? settings : {};
-  const init_promise = _converse_headless_utils_core__WEBPACK_IMPORTED_MODULE_11__["default"].getResolveablePromise();
+function initPlugins() {
+  // If initialize gets called a second time (e.g. during tests), then we
+  // need to re-apply all plugins (for a new converse instance), and we
+  // therefore need to clear this array that prevents plugins from being
+  // initialized twice.
+  // If initialize is called for the first time, then this array is empty
+  // in any case.
+  _converse.pluggable.initialized_plugins = [];
+
+  const whitelist = _converse.core_plugins.concat(_converse.whitelisted_plugins);
+
+  if (_converse.view_mode === 'embedded') {
+    _lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.forEach([// eslint-disable-line lodash/prefer-map
+    "converse-bookmarks", "converse-controlbox", "converse-headline", "converse-register"], name => {
+      _converse.blacklisted_plugins.push(name);
+    });
+  }
 
-  _lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.each(PROMISES, addPromise);
+  _converse.pluggable.initializePlugins({
+    'updateSettings'() {
+      _converse.log("(DEPRECATION) " + "The `updateSettings` method has been deprecated. " + "Please use `_converse.api.settings.update` instead.", strophe_js__WEBPACK_IMPORTED_MODULE_0__["Strophe"].LogLevel.WARN);
 
-  if (!_lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.isUndefined(_converse.connection)) {
-    // Looks like _converse.initialized was called again without logging
-    // out or disconnecting in the previous session.
-    // This happens in tests. We therefore first clean up.
-    Backbone.history.stop();
+      _converse.api.settings.update.apply(_converse, arguments);
+    },
+
+    '_converse': _converse
+  }, whitelist, _converse.blacklisted_plugins);
+
+  _converse.emit('pluginsInitialized');
+}
+
+function initClientConfig() {
+  /* The client config refers to configuration of the client which is
+   * independent of any particular user.
+   * What this means is that config values need to persist across
+   * user sessions.
+   */
+  const id = b64_sha1('converse.client-config');
+  _converse.config = new Backbone.Model({
+    'id': id,
+    'trusted': _converse.trusted && true || false,
+    'storage': _converse.trusted ? 'local' : 'session'
+  });
+  _converse.config.browserStorage = new Backbone.BrowserStorage.session(id);
 
-    _converse.chatboxviews.closeAllChatBoxes();
+  _converse.config.fetch();
 
-    if (_converse.bookmarks) {
-      _converse.bookmarks.reset();
+  _converse.emit('clientConfigInitialized');
+}
+
+_converse.initConnection = function () {
+  /* Creates a new Strophe.Connection instance if we don't already have one.
+   */
+  if (!_converse.connection) {
+    if (!_converse.bosh_service_url && !_converse.websocket_url) {
+      throw new Error("initConnection: you must supply a value for either the bosh_service_url or websocket_url or both.");
     }
 
-    delete _converse.controlboxtoggle;
-    delete _converse.chatboxviews;
+    if (('WebSocket' in window || 'MozWebSocket' in window) && _converse.websocket_url) {
+      _converse.connection = new strophe_js__WEBPACK_IMPORTED_MODULE_0__["Strophe"].Connection(_converse.websocket_url, _converse.connection_options);
+    } else if (_converse.bosh_service_url) {
+      _converse.connection = new strophe_js__WEBPACK_IMPORTED_MODULE_0__["Strophe"].Connection(_converse.bosh_service_url, _lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.assignIn(_converse.connection_options, {
+        'keepalive': _converse.keepalive
+      }));
+    } else {
+      throw new Error("initConnection: this browser does not support websockets and bosh_service_url wasn't specified.");
+    }
+  }
 
-    _converse.connection.reset();
+  _converse.emit('connectionInitialized');
+};
 
-    _converse.stopListening();
+function setUpXMLLogging() {
+  strophe_js__WEBPACK_IMPORTED_MODULE_0__["Strophe"].log = function (level, msg) {
+    _converse.log(msg, level);
+  };
 
-    _converse.tearDown();
+  if (_converse.debug) {
+    _converse.connection.xmlInput = function (body) {
+      _converse.log(body.outerHTML, strophe_js__WEBPACK_IMPORTED_MODULE_0__["Strophe"].LogLevel.DEBUG, 'color: darkgoldenrod');
+    };
+
+    _converse.connection.xmlOutput = function (body) {
+      _converse.log(body.outerHTML, strophe_js__WEBPACK_IMPORTED_MODULE_0__["Strophe"].LogLevel.DEBUG, 'color: darkcyan');
+    };
+  }
+}
+
+function finishInitialization() {
+  initPlugins();
+  initClientConfig();
+
+  _converse.initConnection();
+
+  setUpXMLLogging();
+
+  _converse.logIn();
+
+  _converse.registerGlobalEventHandlers();
+
+  if (!Backbone.history.started) {
+    Backbone.history.start();
+  }
+
+  if (_converse.idle_presence_timeout > 0) {
+    _converse.on('addClientFeatures', () => {
+      _converse.api.disco.own.features.add(strophe_js__WEBPACK_IMPORTED_MODULE_0__["Strophe"].NS.IDLE);
+    });
+  }
+}
+
+function cleanup() {
+  // Looks like _converse.initialized was called again without logging
+  // out or disconnecting in the previous session.
+  // This happens in tests. We therefore first clean up.
+  Backbone.history.stop();
+
+  _converse.chatboxviews.closeAllChatBoxes();
+
+  window.localStorage.clear();
+  window.sessionStorage.clear();
+
+  if (_converse.bookmarks) {
+    _converse.bookmarks.reset();
+  }
+
+  delete _converse.controlboxtoggle;
+  delete _converse.chatboxviews;
 
-    delete _converse.config;
+  _converse.connection.reset();
 
-    _converse.initClientConfig();
+  _converse.stopListening();
 
-    _converse.off();
+  _converse.tearDown();
+
+  delete _converse.config;
+  initClientConfig();
+
+  _converse.off();
+}
+
+_converse.initialize = function (settings, callback) {
+  settings = !_lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.isUndefined(settings) ? settings : {};
+  const init_promise = _converse_headless_utils_core__WEBPACK_IMPORTED_MODULE_11__["default"].getResolveablePromise();
+
+  _lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.each(PROMISES, addPromise);
+
+  if (!_lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.isUndefined(_converse.connection)) {
+    cleanup();
   }
 
   if ('onpagehide' in window) {
@@ -63169,29 +63288,10 @@ _converse.initialize = function (settings, callback) {
     }
   };
 
-  this.initClientConfig = function () {
-    /* The client config refers to configuration of the client which is
-     * independent of any particular user.
-     * What this means is that config values need to persist across
-     * user sessions.
-     */
-    const id = b64_sha1('converse.client-config');
-    _converse.config = new Backbone.Model({
-      'id': id,
-      'trusted': _converse.trusted && true || false,
-      'storage': _converse.trusted ? 'local' : 'session'
-    });
-    _converse.config.browserStorage = new Backbone.BrowserStorage.session(id);
-
-    _converse.config.fetch();
-
-    _converse.emit('clientConfigInitialized');
-  };
-
   this.initSession = function () {
     const id = b64_sha1('converse.bosh-session');
     _converse.session = new Backbone.Model({
-      'id': id
+      id
     });
     _converse.session.browserStorage = new Backbone.BrowserStorage.session(id);
 
@@ -63456,22 +63556,6 @@ _converse.initialize = function (settings, callback) {
 
   });
 
-  this.setUpXMLLogging = function () {
-    strophe_js__WEBPACK_IMPORTED_MODULE_0__["Strophe"].log = function (level, msg) {
-      _converse.log(msg, level);
-    };
-
-    if (this.debug) {
-      this.connection.xmlInput = function (body) {
-        _converse.log(body.outerHTML, strophe_js__WEBPACK_IMPORTED_MODULE_0__["Strophe"].LogLevel.DEBUG, 'color: darkgoldenrod');
-      };
-
-      this.connection.xmlOutput = function (body) {
-        _converse.log(body.outerHTML, strophe_js__WEBPACK_IMPORTED_MODULE_0__["Strophe"].LogLevel.DEBUG, 'color: darkcyan');
-      };
-    }
-  };
-
   this.fetchLoginCredentials = () => new es6_promise_dist_es6_promise_auto__WEBPACK_IMPORTED_MODULE_3___default.a((resolve, reject) => {
     const xhr = new XMLHttpRequest();
     xhr.open('GET', _converse.credentials_url, true);
@@ -63656,28 +63740,6 @@ _converse.initialize = function (settings, callback) {
     }
   };
 
-  this.initConnection = function () {
-    /* Creates a new Strophe.Connection instance if we don't already have one.
-     */
-    if (!this.connection) {
-      if (!this.bosh_service_url && !this.websocket_url) {
-        throw new Error("initConnection: you must supply a value for either the bosh_service_url or websocket_url or both.");
-      }
-
-      if (('WebSocket' in window || 'MozWebSocket' in window) && this.websocket_url) {
-        this.connection = new strophe_js__WEBPACK_IMPORTED_MODULE_0__["Strophe"].Connection(this.websocket_url, this.connection_options);
-      } else if (this.bosh_service_url) {
-        this.connection = new strophe_js__WEBPACK_IMPORTED_MODULE_0__["Strophe"].Connection(this.bosh_service_url, _lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.assignIn(this.connection_options, {
-          'keepalive': this.keepalive
-        }));
-      } else {
-        throw new Error("initConnection: this browser does not support websockets and bosh_service_url wasn't specified.");
-      }
-    }
-
-    _converse.emit('connectionInitialized');
-  };
-
   this.tearDown = function () {
     /* Remove those views which are only allowed with a valid
      * connection.
@@ -63698,37 +63760,6 @@ _converse.initialize = function (settings, callback) {
     _converse.emit('afterTearDown');
 
     return _converse;
-  };
-
-  this.initPlugins = function () {
-    // If initialize gets called a second time (e.g. during tests), then we
-    // need to re-apply all plugins (for a new converse instance), and we
-    // therefore need to clear this array that prevents plugins from being
-    // initialized twice.
-    // If initialize is called for the first time, then this array is empty
-    // in any case.
-    _converse.pluggable.initialized_plugins = [];
-
-    const whitelist = _converse.core_plugins.concat(_converse.whitelisted_plugins);
-
-    if (_converse.view_mode === 'embedded') {
-      _lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.forEach([// eslint-disable-line lodash/prefer-map
-      "converse-bookmarks", "converse-controlbox", "converse-headline", "converse-register"], name => {
-        _converse.blacklisted_plugins.push(name);
-      });
-    }
-
-    _converse.pluggable.initializePlugins({
-      'updateSettings'() {
-        _converse.log("(DEPRECATION) " + "The `updateSettings` method has been deprecated. " + "Please use `_converse.api.settings.update` instead.", strophe_js__WEBPACK_IMPORTED_MODULE_0__["Strophe"].LogLevel.WARN);
-
-        _converse.api.settings.update.apply(_converse, arguments);
-      },
-
-      '_converse': _converse
-    }, whitelist, _converse.blacklisted_plugins);
-
-    _converse.emit('pluginsInitialized');
   }; // Initialization
   // --------------
   // This is the end of the initialize method.
@@ -63738,30 +63769,6 @@ _converse.initialize = function (settings, callback) {
     this.connection = settings.connection;
   }
 
-  function finishInitialization() {
-    _converse.initPlugins();
-
-    _converse.initClientConfig();
-
-    _converse.initConnection();
-
-    _converse.setUpXMLLogging();
-
-    _converse.logIn();
-
-    _converse.registerGlobalEventHandlers();
-
-    if (!Backbone.history.started) {
-      Backbone.history.start();
-    }
-
-    if (_converse.idle_presence_timeout > 0) {
-      _converse.on('addClientFeatures', () => {
-        _converse.api.disco.own.features.add(strophe_js__WEBPACK_IMPORTED_MODULE_0__["Strophe"].NS.IDLE);
-      });
-    }
-  }
-
   if (!_lodash_noconflict__WEBPACK_IMPORTED_MODULE_4___default.a.isUndefined(_converse.connection) && _converse.connection.service === 'jasmine tests') {
     finishInitialization();
     return _converse;

+ 1 - 1
spec/converse.js

@@ -16,7 +16,7 @@
                 var connection = _converse.connection;
                 delete _converse.bosh_service_url;
                 delete _converse.connection;
-                expect(_converse.initConnection.bind(_converse)).toThrow(
+                expect(_converse.initConnection).toThrow(
                     new Error("initConnection: you must supply a value for either the bosh_service_url or websocket_url or both."));
                 _converse.bosh_service_url = url;
                 _converse.connection = connection;

+ 144 - 134
src/headless/converse-core.js

@@ -56,6 +56,11 @@ _.templateSettings = {
     'imports': { '_': _ }
 };
 
+// Setting wait to 59 instead of 60 to avoid timing conflicts with the
+// webserver, which is often also set to 60 and might therefore sometimes
+// return a 504 error page instead of passing through to the BOSH proxy.
+const BOSH_WAIT = 59;
+
 /**
  * A private, closured object containing the private api (via `_converse.api`)
  * as well as private methods and internal data-structures.
@@ -67,11 +72,16 @@ const _converse = {
     'promises': {}
 }
 
+_converse.VERSION_NAME = "v4.0.5";
+
 _.extend(_converse, Backbone.Events);
 
-_converse.VERSION_NAME = "v4.0.5";
+// Make converse pluggable
+pluggable.enable(_converse, '_converse', 'pluggable');
 
 // Core plugins are whitelisted automatically
+// These are just the @converse/headless plugins, for the full converse,
+// the other plugins are whitelisted in src/converse.js
 _converse.core_plugins = [
     'converse-chatboxes',
     'converse-core',
@@ -83,14 +93,6 @@ _converse.core_plugins = [
     'converse-vcard'
 ];
 
-// Setting wait to 59 instead of 60 to avoid timing conflicts with the
-// webserver, which is often also set to 60 and might therefore sometimes
-// return a 504 error page instead of passing through to the BOSH proxy.
-const BOSH_WAIT = 59;
-
-// Make converse pluggable
-pluggable.enable(_converse, '_converse', 'pluggable');
-
 _converse.keycodes = {
     TAB: 9,
     ENTER: 13,
@@ -317,29 +319,143 @@ _converse.isSingleton = function () {
 _converse.router = new Backbone.Router();
 
 
+function initPlugins() {
+    // If initialize gets called a second time (e.g. during tests), then we
+    // need to re-apply all plugins (for a new converse instance), and we
+    // therefore need to clear this array that prevents plugins from being
+    // initialized twice.
+    // If initialize is called for the first time, then this array is empty
+    // in any case.
+    _converse.pluggable.initialized_plugins = [];
+    const whitelist = _converse.core_plugins.concat(
+        _converse.whitelisted_plugins);
+
+    if (_converse.view_mode === 'embedded') {
+        _.forEach([ // eslint-disable-line lodash/prefer-map
+            "converse-bookmarks",
+            "converse-controlbox",
+            "converse-headline",
+            "converse-register"
+        ], (name) => {
+            _converse.blacklisted_plugins.push(name)
+        });
+    }
+
+    _converse.pluggable.initializePlugins({
+        'updateSettings' () {
+            _converse.log(
+                "(DEPRECATION) "+
+                "The `updateSettings` method has been deprecated. "+
+                "Please use `_converse.api.settings.update` instead.",
+                Strophe.LogLevel.WARN
+            )
+            _converse.api.settings.update.apply(_converse, arguments);
+        },
+        '_converse': _converse
+    }, whitelist, _converse.blacklisted_plugins);
+    _converse.emit('pluginsInitialized');
+}
+
+function initClientConfig () {
+    /* The client config refers to configuration of the client which is
+     * independent of any particular user.
+     * What this means is that config values need to persist across
+     * user sessions.
+     */
+    const id = b64_sha1('converse.client-config');
+    _converse.config = new Backbone.Model({
+        'id': id,
+        'trusted': _converse.trusted && true || false,
+        'storage': _converse.trusted ? 'local' : 'session'
+    });
+    _converse.config.browserStorage = new Backbone.BrowserStorage.session(id);
+    _converse.config.fetch();
+    _converse.emit('clientConfigInitialized');
+}
+
+_converse.initConnection = function () {
+    /* Creates a new Strophe.Connection instance if we don't already have one.
+     */
+    if (!_converse.connection) {
+        if (!_converse.bosh_service_url && ! _converse.websocket_url) {
+            throw new Error("initConnection: you must supply a value for either the bosh_service_url or websocket_url or both.");
+        }
+        if (('WebSocket' in window || 'MozWebSocket' in window) && _converse.websocket_url) {
+            _converse.connection = new Strophe.Connection(_converse.websocket_url, _converse.connection_options);
+        } else if (_converse.bosh_service_url) {
+            _converse.connection = new Strophe.Connection(
+                _converse.bosh_service_url,
+                _.assignIn(_converse.connection_options, {'keepalive': _converse.keepalive})
+            );
+        } else {
+            throw new Error("initConnection: this browser does not support websockets and bosh_service_url wasn't specified.");
+        }
+    }
+    _converse.emit('connectionInitialized');
+}
+
+
+function setUpXMLLogging () {
+    Strophe.log = function (level, msg) {
+        _converse.log(msg, level);
+    };
+    if (_converse.debug) {
+        _converse.connection.xmlInput = function (body) {
+            _converse.log(body.outerHTML, Strophe.LogLevel.DEBUG, 'color: darkgoldenrod');
+        };
+        _converse.connection.xmlOutput = function (body) {
+            _converse.log(body.outerHTML, Strophe.LogLevel.DEBUG, 'color: darkcyan');
+        };
+    }
+}
+
+
+function finishInitialization () {
+    initPlugins();
+    initClientConfig();
+    _converse.initConnection();
+    setUpXMLLogging();
+    _converse.logIn();
+    _converse.registerGlobalEventHandlers();
+    if (!Backbone.history.started) {
+        Backbone.history.start();
+    }
+    if (_converse.idle_presence_timeout > 0) {
+        _converse.on('addClientFeatures', () => {
+            _converse.api.disco.own.features.add(Strophe.NS.IDLE);
+        });
+    }
+}
+
+
+function cleanup () {
+    // Looks like _converse.initialized was called again without logging
+    // out or disconnecting in the previous session.
+    // This happens in tests. We therefore first clean up.
+    Backbone.history.stop();
+    _converse.chatboxviews.closeAllChatBoxes();
+    window.localStorage.clear();
+    window.sessionStorage.clear();
+    if (_converse.bookmarks) {
+        _converse.bookmarks.reset();
+    }
+    delete _converse.controlboxtoggle;
+    delete _converse.chatboxviews;
+    _converse.connection.reset();
+    _converse.stopListening();
+    _converse.tearDown();
+    delete _converse.config;
+    initClientConfig();
+    _converse.off();
+}
+
+
 _converse.initialize = function (settings, callback) {
     settings = !_.isUndefined(settings) ? settings : {};
     const init_promise = u.getResolveablePromise();
-
     _.each(PROMISES, addPromise);
-
     if (!_.isUndefined(_converse.connection)) {
-        // Looks like _converse.initialized was called again without logging
-        // out or disconnecting in the previous session.
-        // This happens in tests. We therefore first clean up.
-        Backbone.history.stop();
-        _converse.chatboxviews.closeAllChatBoxes();
-        if (_converse.bookmarks) {
-            _converse.bookmarks.reset();
-        }
-        delete _converse.controlboxtoggle;
-        delete _converse.chatboxviews;
-        _converse.connection.reset();
-        _converse.stopListening();
-        _converse.tearDown();
-        delete _converse.config;
-        _converse.initClientConfig();
-        _converse.off();
+        cleanup();
     }
 
     if ('onpagehide' in window) {
@@ -663,26 +779,10 @@ _converse.initialize = function (settings, callback) {
         }
     }
 
-    this.initClientConfig = function () {
-        /* The client config refers to configuration of the client which is
-         * independent of any particular user.
-         * What this means is that config values need to persist across
-         * user sessions.
-         */
-        const id = b64_sha1('converse.client-config');
-        _converse.config = new Backbone.Model({
-            'id': id,
-            'trusted': _converse.trusted && true || false,
-            'storage': _converse.trusted ? 'local' : 'session'
-        });
-        _converse.config.browserStorage = new Backbone.BrowserStorage.session(id);
-        _converse.config.fetch();
-        _converse.emit('clientConfigInitialized');
-    };
 
     this.initSession = function () {
         const id = b64_sha1('converse.bosh-session');
-        _converse.session = new Backbone.Model({'id': id});
+        _converse.session = new Backbone.Model({id});
         _converse.session.browserStorage = new Backbone.BrowserStorage.session(id);
         _converse.session.fetch();
         _converse.emit('sessionInitialized');
@@ -912,19 +1012,6 @@ _converse.initialize = function (settings, callback) {
         }
     });
 
-    this.setUpXMLLogging = function () {
-        Strophe.log = function (level, msg) {
-            _converse.log(msg, level);
-        };
-        if (this.debug) {
-            this.connection.xmlInput = function (body) {
-                _converse.log(body.outerHTML, Strophe.LogLevel.DEBUG, 'color: darkgoldenrod');
-            };
-            this.connection.xmlOutput = function (body) {
-                _converse.log(body.outerHTML, Strophe.LogLevel.DEBUG, 'color: darkcyan');
-            };
-        }
-    };
 
     this.fetchLoginCredentials = () =>
         new Promise((resolve, reject) => {
@@ -1107,28 +1194,6 @@ _converse.initialize = function (settings, callback) {
         }
     };
 
-    this.initConnection = function () {
-        /* Creates a new Strophe.Connection instance if we don't already have one.
-         */
-        if (!this.connection) {
-            if (!this.bosh_service_url && ! this.websocket_url) {
-                throw new Error("initConnection: you must supply a value for either the bosh_service_url or websocket_url or both.");
-            }
-            if (('WebSocket' in window || 'MozWebSocket' in window) && this.websocket_url) {
-                this.connection = new Strophe.Connection(this.websocket_url, this.connection_options);
-            } else if (this.bosh_service_url) {
-                this.connection = new Strophe.Connection(
-                    this.bosh_service_url,
-                    _.assignIn(this.connection_options, {'keepalive': this.keepalive})
-                );
-            } else {
-                throw new Error("initConnection: this browser does not support websockets and bosh_service_url wasn't specified.");
-            }
-        }
-        _converse.emit('connectionInitialized');
-    };
-
-
     this.tearDown = function () {
         /* Remove those views which are only allowed with a valid
          * connection.
@@ -1147,42 +1212,6 @@ _converse.initialize = function (settings, callback) {
         return _converse;
     };
 
-    this.initPlugins = function () {
-        // If initialize gets called a second time (e.g. during tests), then we
-        // need to re-apply all plugins (for a new converse instance), and we
-        // therefore need to clear this array that prevents plugins from being
-        // initialized twice.
-        // If initialize is called for the first time, then this array is empty
-        // in any case.
-        _converse.pluggable.initialized_plugins = [];
-        const whitelist = _converse.core_plugins.concat(
-            _converse.whitelisted_plugins);
-
-        if (_converse.view_mode === 'embedded') {
-            _.forEach([ // eslint-disable-line lodash/prefer-map
-                "converse-bookmarks",
-                "converse-controlbox",
-                "converse-headline",
-                "converse-register"
-            ], (name) => {
-                _converse.blacklisted_plugins.push(name)
-            });
-        }
-
-        _converse.pluggable.initializePlugins({
-            'updateSettings' () {
-                _converse.log(
-                    "(DEPRECATION) "+
-                    "The `updateSettings` method has been deprecated. "+
-                    "Please use `_converse.api.settings.update` instead.",
-                    Strophe.LogLevel.WARN
-                )
-                _converse.api.settings.update.apply(_converse, arguments);
-            },
-            '_converse': _converse
-        }, whitelist, _converse.blacklisted_plugins);
-        _converse.emit('pluginsInitialized');
-    };
 
     // Initialization
     // --------------
@@ -1191,25 +1220,6 @@ _converse.initialize = function (settings, callback) {
         this.connection = settings.connection;
     }
 
-    function finishInitialization () {
-        _converse.initPlugins();
-        _converse.initClientConfig();
-        _converse.initConnection();
-        _converse.setUpXMLLogging();
-        _converse.logIn();
-        _converse.registerGlobalEventHandlers();
-
-        if (!Backbone.history.started) {
-            Backbone.history.start();
-        }
-
-        if (_converse.idle_presence_timeout > 0) {
-            _converse.on('addClientFeatures', () => {
-                _converse.api.disco.own.features.add(Strophe.NS.IDLE);
-            });
-        }
-    }
-
     if (!_.isUndefined(_converse.connection) &&
             _converse.connection.service === 'jasmine tests') {
         finishInitialization();