Commit 7dc685b002d for nodejs
commit 7dc685b002ddba857003f9d893d37310faabd080
Author: Alexandre Zollinger Chohfi <chohfi@outlook.com>
Date: Sat Nov 28 10:18:32 2026 -0800
build: delay-load rarely used system DLLs on Windows
node.exe imports crypt32, dbghelp, iphlpapi, ole32, shell32, userenv
and winmm, so every process loads them, and the DLLs they depend on,
at start-up. They are only needed by less common code paths such as
the system certificate store, network interface queries and
diagnostic reports.
Delay-load them so they are loaded on first use. On Windows 11 this
takes `node -e 0` from 35 to 26 loaded images and saves about 2.5 ms
per process.
Signed-off-by: Alexandre Zollinger Chohfi <alzollin@microsoft.com>
PR-URL: https://github.com/nodejs/node/pull/67098
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
diff --git a/node.gyp b/node.gyp
index 3c8ec1e9afe..86ae0adbeee 100644
--- a/node.gyp
+++ b/node.gyp
@@ -723,6 +723,24 @@
}],
[ 'OS=="win"', {
'sources': [ 'src/res/node.rc' ],
+ # These system DLLs are only needed by less common code paths
+ # (system certificate store, network interface queries,
+ # diagnostic reports and so on). Loading them on first use
+ # instead of at process start-up saves about 2.5 ms per process.
+ 'libraries': [ 'delayimp.lib' ],
+ 'msvs_settings': {
+ 'VCLinkerTool': {
+ 'DelayLoadDLLs': [
+ 'crypt32.dll',
+ 'dbghelp.dll',
+ 'iphlpapi.dll',
+ 'ole32.dll',
+ 'shell32.dll',
+ 'userenv.dll',
+ 'winmm.dll',
+ ],
+ },
+ },
}],
],
}],