Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

As I add more and more plugins and configurations to my emacs' init.el , it's startup is getting more and more slow. Is there any way to avoid this?

share|improve this question

2 Answers 2

up vote 18 down vote accepted

Your .emacs or init.el shouldn't have many require or load commands, it should mostly have autoload. The autoload function tells Emacs “if you ever need this function, load that file”. This way, the file is only loaded when and if you actually use the function. You only need require (or very rarely load) in two cases:

  • if there's a customization that needs to go into effect immediately (e.g. (require 'cl), a color theme);
  • if what you're loading is a small file that contains the autoloads and other start-up definitions of a package (e.g. (require 'tex-site).

If you're not doing this already, calling autoload for things like mode-specific customizations can cut your startup time down significantly, because Emacs will have to load fewer files.

Furthermore, make sure your files are byte-compiled; they'll load a little faster (less CPU time). Call M-x emacs-lisp-byte-compile on each .el file, or M-x byte-recompile-directory (these commands are in the Emacs-Lisp menu).

Finally, note that load times don't matter so much because you should be starting Emacs at most once per session. Start Emacs automatically when you log in, either with a window or in the background with the --daemon option. Then, to edit a file, run emacsclient. You can also tell emacsclient to start Emacs if it's not running yet if you'd rather not start it when you log in.

share|improve this answer

You can compile it as an .elc file (M-x byte-compile-file)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.
{"cc_re__cc_re__cc_by_sa_3_0": ["                  <li><a href=\"//area51.stackexchange.com\" title=\"proposing new sites in the Stack Exchange network\">Area 51</a></li>\r\n                        <li><a href=\"//careers.stackoverflow.com\">Stack Overflow Careers</a></li>\r\n                    \r\n                </ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &#169; 2015 stack exchange inc; user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc by-sa 3.0</a> \r\n                with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2015.5.6.2555\r\n            </div>\r\n            \r\n        </div>\r\n    </div>\r\n    <noscript>\r\n        <div id=\"noscript-warning\">Stack Overflow works best with JavaScript enabled<img src=\"http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif\" alt=\"\" class=\"dno\"></div>\r\n    </nosc"], "copyright__copyright__copyright": [" background with the --daemon option. Then, to edit a file, run emacsclient. You can also tell emacsclient to start Emacs if it's not running yet if you'd rather not start it when you log in.\n\nshare|improve this answer\n\nYou can compile it as an .elc file (M-x byte-compile-file)\n\nshare|improve this answer\n\nYour Answer\n\n\u00a0\ndiscard\n\nBy posting your answer, you agree to the privacy policy and terms of service.\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}