Skip to content

Instantly share code, notes, and snippets.

@yongkangchen
Last active September 13, 2022 13:15
Show Gist options
  • Save yongkangchen/86f0284291584d0b7c78 to your computer and use it in GitHub Desktop.
Save yongkangchen/86f0284291584d0b7c78 to your computer and use it in GitHub Desktop.
boom!!! Here is a hack solution to make atom start faster. For Atom <= v0.170.0
Atom.prototype.startEditorWindow = function() {
var CommandInstaller, dimensions, maximize, resourcePath, safeMode, _ref;
_ref = this.getLoadSettings(), resourcePath = _ref.resourcePath, safeMode = _ref.safeMode;
CommandInstaller = require('./command-installer');
CommandInstaller.installAtomCommand(resourcePath, false, function(error) {
if (error != null) {
return console.warn(error.message);
}
});
CommandInstaller.installApmCommand(resourcePath, false, function(error) {
if (error != null) {
return console.warn(error.message);
}
});
dimensions = this.restoreWindowDimensions();
// this.loadConfig();
this.themes.loadBaseStylesheets();
this.keymaps.loadBundledKeymaps();
setImmediate((function(_this) {
return function() {
_this.deserializeEditorWindow();
_this.themes.activatePackages();
_this.packages.activatePackage("tabs");
_this.packages.activatePackage("status-bar");
_this.packages.activatePackage("tree-view");
_this.loadConfig();
setTimeout(function(){
_this.packages.loadPackages();
_this.watchProjectPath();
_this.packages.activate();
_this.keymaps.loadUserKeymap();
if (!safeMode) {
_this.requireUserInitScript();
}
_this.menu.update();
_this.subscribe(_this.config.onDidChange('core.autoHideMenuBar', (function(_this) {
return function(_arg) {
var newValue;
newValue = _arg.newValue;
return _this.setAutoHideMenuBar(newValue);
};
})(_this)));
if (_this.config.get('core.autoHideMenuBar')) {
_this.setAutoHideMenuBar(true);
}
}, 200); //NOTE: here can change
};
})(this));
// this.packages.loadPackages();
// this.deserializeEditorWindow();
// this.watchProjectPath();
// this.packages.activate();
// this.keymaps.loadUserKeymap();
// if (!safeMode) {
// this.requireUserInitScript();
// }
// this.menu.update();
// this.subscribe(this.config.onDidChange('core.autoHideMenuBar', (function(_this) {
// return function(_arg) {
// var newValue;
// newValue = _arg.newValue;
// return _this.setAutoHideMenuBar(newValue);
// };
// })(this)));
// if (this.config.get('core.autoHideMenuBar')) {
// this.setAutoHideMenuBar(true);
// }
maximize = (dimensions != null ? dimensions.maximized : void 0) && process.platform !== 'darwin';
return this.displayWindow({
maximize: maximize
});
};
@yongkangchen
Copy link
Author

For atom v0.192

    Atom.prototype.startEditorWindow = function() {
      var CommandInstaller, dimensions, maximize, resourcePath, safeMode, _ref3;
      _ref3 = this.getLoadSettings(), resourcePath = _ref3.resourcePath, safeMode = _ref3.safeMode;

      CommandInstaller = require('./command-installer');
      CommandInstaller.installAtomCommand(resourcePath, false, function(error) {
        if (error != null) {
          return console.warn(error.message);
        }
      });
      CommandInstaller.installApmCommand(resourcePath, false, function(error) {
        if (error != null) {
          return console.warn(error.message);
        }
      });

      dimensions = this.restoreWindowDimensions(); // 18ms
      this.loadConfig(); // 9ms
      this.keymaps.loadBundledKeymaps(); // 8ms
      this.themes.loadBaseStylesheets(); // 29ms

      this.themes.activatePackages();
      this.deserializeEditorWindow(); // 161ms
      setImmediate((function(_this) {
        return function() {

          _this.packages.activatePackage("tabs"); //50ms
          _this.packages.activatePackage("status-bar");//24ms
          _this.packages.activatePackage("tree-view");//18ms

          setTimeout(function(){
            _this.packages.loadPackages(); // 210ms
            _this.watchProjectPath();
            _this.packages.activate(); // 309ms
            _this.keymaps.loadUserKeymap();

            if (!safeMode) {
              _this.requireUserInitScript();
            }

            _this.menu.update();
            _this.disposables.add(_this.config.onDidChange('core.autoHideMenuBar', (function(_this) {
              return function(_arg) {
                var newValue;
                newValue = _arg.newValue;
                return _this.setAutoHideMenuBar(newValue);
              };
            })(_this)));

            if (_this.config.get('core.autoHideMenuBar')) {
              _this.setAutoHideMenuBar(true);
            }
            _this.openInitialEmptyEditorIfNecessary(); // 8ms
          }, 100);

        };
      })(this));

      maximize = (dimensions != null ? dimensions.maximized : void 0) && process.platform !== 'darwin';
      return this.displayWindow({
        maximize: maximize
      });
    };

@antonbrams
Copy link

The Path on Mac isn't exist, can you update it please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment