Node.js based forum software built for the modern web
require npm module only as needed - shaves off a full second of loading time yay
psychobunnydee5d18439cf
diff --git a/src/plugins.js b/src/plugins.jsindex fbc74e85ac..2e5202e240 100644--- a/src/plugins.js+++ b/src/plugins.js@@ -1,5 +1,6 @@'use strict';+var start = process.hrtime();var fs = require('fs'),path = require('path'),async = require('async'),@@ -18,10 +19,12 @@ var fs = require('fs'),controllers = require('./controllers'),app, middleware;+process.profile('requiring modules', start);(function(Plugins) {-+var start = process.hrtime();require('./plugins/install')(Plugins);+process.profile('requiring modules 2', start);require('./plugins/load')(Plugins);require('./plugins/hooks')(Plugins);diff --git a/src/plugins/install.js b/src/plugins/install.jsindex de63cd9f3b..6d6865301a 100644--- a/src/plugins/install.js+++ b/src/plugins/install.js@@ -2,7 +2,6 @@var winston = require('winston'),async = require('async'),- npm = require('npm'),path = require('path'),fs = require('fs'),nconf = require('nconf'),@@ -88,10 +87,10 @@ module.exports = function(Plugins) {next();},function(next) {- npm.load({}, next);+ require('npm').load({}, next);},function(res, next) {- npm.commands[type](installed ? id : [id + '@' + (version || 'latest')], next);+ require('npm').commands[type](installed ? id : [id + '@' + (version || 'latest')], next);}], function(err) {if (err) {@@ -111,10 +110,10 @@ module.exports = function(Plugins) {function upgrade(id, version, callback) {async.waterfall([function(next) {- npm.load({}, next);+ require('npm').load({}, next);},function(res, next) {- npm.commands.install([id + '@' + (version || 'latest')], next);+ require('npm').commands.install([id + '@' + (version || 'latest')], next);}], callback);}