From c49371053f2ac0bbc456e7453cedd6a502a9eca6 Mon Sep 17 00:00:00 2001 From: Alexandre Zollinger Chohfi Date: Thu, 22 Oct 2026 15:35:45 -0700 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 --- node.gyp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/node.gyp b/node.gyp index 714609b03e6..a4c958959e4 100644 --- a/node.gyp +++ b/node.gyp @@ -707,6 +707,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', + ], + }, + }, }], ], }],