Skip to content

Add strict directive to cjs files for better performance #4300

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Fdawgs opened this issue Feb 27, 2025 · 2 comments · Fixed by #4301
Closed

Add strict directive to cjs files for better performance #4300

Fdawgs opened this issue Feb 27, 2025 · 2 comments · Fixed by #4301

Comments

@Fdawgs
Copy link
Contributor

Fdawgs commented Feb 27, 2025

It would be beneficial to add the 'use strict' directive to all cjs files in this repo. Strict mode can improve performance by eliminating some JavaScript features that hinder optimizations. It also helps avoid subtle bugs by enforcing more consistent scoping and variable declarations.

The MDN article on strict mode alludes to it, but the V8 JS engine used by Node will use more optimised execution paths when strict mode is enabled. See related Stack Overflow discussion for an example.

I'm happy to make a PR for this.

@escapedcat
Copy link
Member

We only have like ~2 cjs in this project? Not sure what the impact would be. But sure go ahead.

@janbiasi
Copy link
Contributor

Didn't know about that one, but I'd be very interested in seeing a benchmark of the effective difference! 👍🏽

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants