Skip to content

Conversation

pudinaman
Copy link

No description provided.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/loaders

@nodejs-github-bot 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
@pudinaman
Copy link
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:

Copy link

@jsumners-nr jsumners-nr left a comment

Choose a reason for hiding this comment

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

Duplicate of #59815

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.

3 participants