From 7dc685b002ddba857003f9d893d37310faabd080 Mon Sep 17 00:00:00 2001 From: Alexandre Zollinger Chohfi Date: Sat, 28 Nov 2026 10:18:32 -0800 Subject: [PATCH] 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 PR-URL: https://github.com/nodejs/node/pull/67098 Reviewed-By: James M Snell Reviewed-By: Stefan Stojanovic --- node.gyp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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', + ], + }, + }, }], ], }],