Diff
1diff --git a/plugins/nvm/README.md b/plugins/nvm/README.md
2index 2515da9e8a560e810db77deda87272acaebd1d6c..ab71185cba0193963fd36514cc07bfd93b468268 100644
3--- a/plugins/nvm/README.md
4+++ b/plugins/nvm/README.md
5@@ -16,3 +16,7 @@ plugins=(... nvm)
6
7 - **`NVM_HOMEBREW`**: if you installed nvm via Homebrew, in a directory other than `/usr/local/opt/nvm`, you
8 can set `NVM_HOMEBREW` to be the directory where you installed it.
9+
10+- **`NVM_LAZY`**: if you want the plugin to defer the load of nvm to speed-up the start of your zsh session,
11+ set `NVM_LAZY` to `1`. This will use the `--no-use` parameter when loading nvm, and will create a function
12+ for `node`, `npm` and `yarn`, so when you call either of these three, nvm will load with `nvm use default`.
13diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh
14index 640f1d45c77c984940e4c63d9ea42fbdb3b31137..164be5907f9813d34b51edfed324375a231e8048 100644
15--- a/plugins/nvm/nvm.plugin.zsh
16+++ b/plugins/nvm/nvm.plugin.zsh
17@@ -12,21 +12,23 @@ which nvm &> /dev/null && return
18
19 if [[ -f "$NVM_DIR/nvm.sh" ]]; then
20 # Load nvm if it exists in $NVM_DIR
21- source "$NVM_DIR/nvm.sh" --no-use
22+ source "$NVM_DIR/nvm.sh" ${NVM_LAZY+"--no-use"}
23 else
24 # Otherwise try to load nvm installed via Homebrew
25 # User can set this if they have an unusual Homebrew setup
26 NVM_HOMEBREW="${NVM_HOMEBREW:-/usr/local/opt/nvm}"
27 # Load nvm from Homebrew location if it exists
28- [[ -f "$NVM_HOMEBREW/nvm.sh" ]] && source "$NVM_HOMEBREW/nvm.sh" --no-use
29+ [[ -f "$NVM_HOMEBREW/nvm.sh" ]] && source "$NVM_HOMEBREW/nvm.sh" ${NVM_LAZY+"--no-use"}
30 fi
31
32 # Call nvm when first using node, npm or yarn
33-function node npm yarn {
34- unfunction node npm yarn
35- nvm use default
36- command "$0" "$@"
37-}
38+if (( $+NVM_LAZY )); then
39+ function node npm yarn {
40+ unfunction node npm yarn
41+ nvm use default
42+ command "$0" "$@"
43+ }
44+fi
45
46 # Load nvm bash completion
47 for nvm_completion in "$NVM_DIR/bash_completion" "$NVM_HOMEBREW/etc/bash_completion.d/nvm"; do