Last active
September 13, 2022 13:15
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
}); | |
}; |
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
});
};
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
After discuss in why-is-atom-so-slow, I pull a request
Better user experience for start atom
: atom/atom#4269.Today, I do a deep review the atom source code, and find a hack solution to make atom start faster:
this is the final modify screen video demo:
https://drive.google.com/file/d/0B8i7zRr2bfCAV0NoeG50dURMaW8/view?usp=sharing
What It Is
It delay the config file load, and the packages load and active, which cost much time on start.
After change, atom only load and active the must packages on start, which is ui theme、syntax theme、tabs、status-bar、tree-view.
Then delay to load and active other package. Window and mainly package will show quickly.
How To Do:
1、open atom.js
for mac:
/Applications/Atom.app/Contents/Resources/app/src/atom.js
for win8:
2、replace the below function
Atom.prototype.startEditorWindow
3、you can test and change the setTimeout time to adapt your computer.
4、notice that you should modify atom.js again after you update the atom.