Zsh Startup Order and Zinit Placement
Summary
Section titled “Summary”Zinit is sourced early in .zshrc and replaces the traditional plugin-load-then-compinit pattern with a deferred loading model that keeps the prompt fast regardless of how many plugins are configured.
Details
Section titled “Details”Traditional .zshrc evaluation order:
- Environment variables and path setup
- Source each plugin (blocking)
- Call
compinit - Prompt appears
With Zinit the order becomes:
- Declare any
$ZINIThash overrides - Source
zinit.zsh(bootstrap + interceptcompdef) - Optionally load synchronous plugins (those that must be available before the first prompt)
- Declare Turbo-mode plugins with
waitice (they are queued, not yet loaded) - If not using Turbo: call
autoload -Uz compinit; compinit, thenzinit cdreplay -q - Prompt appears immediately
- Turbo-queued plugins load asynchronously in the background
With Turbo mode, compinit is deferred into an atinit or atload hook on the last completion-related plugin. Zinit’s compdef intercept ensures completions work correctly even though compinit has not yet run when the plugins are declared.
Zinit does not use $FPATH entries per plugin (unlike traditional managers), so $FPATH stays clean regardless of the number of plugins loaded.
On systems where /etc/zshrc calls compinit globally (Ubuntu, NixOS), that call should be suppressed to avoid double-initialization overhead.
Examples
Section titled “Examples”# ~/.zshrc skeleton with Zinit (non-Turbo)ZINIT_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/zinit/zinit.git"[ ! -d $ZINIT_HOME ] && mkdir -p "$(dirname $ZINIT_HOME)"[ ! -d $ZINIT_HOME/.git ] && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"source "${ZINIT_HOME}/zinit.zsh"
zinit load some/pluginzinit light other/plugin
autoload -Uz compinitcompinitzinit cdreplay -q
# ~/.zshrc skeleton with Zinit (Turbo)source "${ZINIT_HOME}/zinit.zsh"
zinit lucid wait for \ zsh-users/zsh-autosuggestions \ zdharma-continuum/fast-syntax-highlighting
zi for \ atload"zicompinit; zicdreplay" \ blockf lucid wait \ zsh-users/zsh-completions# compinit is called inside zicompinit, deferred — prompt appears immediately