FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

doc: add note explaining ESM vs CommonJS startup performance difference by pudinaman · Pull Request #60192 · nodejs/node · GitHub

/ node Public

doc: add note explaining ESM vs CommonJS startup performance difference - #60192

Closed
pudinaman wants to merge 1 commit into
nodejs:mainfrom
pudinaman:doc/esm-commonjs-differences
Closed

doc: add note explaining ESM vs CommonJS startup performance difference#60192
pudinaman wants to merge 1 commit into
nodejs:mainfrom
pudinaman:doc/esm-commonjs-differences

Conversation

Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/loaders

nodejs-github-bot added doc Issues and PRs related to the documentations. esm Issues and PRs related to the ECMAScript Modules implementation. labels Oct 10, 2025

Copy link
Copy Markdown
Author

This PR adds documentation explaining the observed performance difference
when importing the 'http' module using ESM (import) vs CommonJS (require).

  • ESM imports eagerly evaluate all properties, causing a slight delay (~8–10 ms)
    for small scripts or CLIs.
  • CommonJS require is lazy, so it loads faster for one-off executions.
  • Recommended usage:
    • Use ESM imports for long-running server apps.
    • Use require for CLI or scripts where startup time matters.

Closes / References:

jsumners-nr left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Duplicate of #59815

Copy link
Copy Markdown
Member

Thank you for the PR, but closing as it was covered by #59686 which was opened/landed first.

BethGriggs closed this Dec 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Issues and PRs related to the documentations. esm Issues and PRs related to the ECMAScript Modules implementation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL