Skip to content
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

Smarter function-passed-to-function heuristics? #1

Open
nolanlawson opened this issue Sep 19, 2016 · 5 comments
Open

Smarter function-passed-to-function heuristics? #1

nolanlawson opened this issue Sep 19, 2016 · 5 comments

Comments

@nolanlawson
Copy link
Owner

Good candidates for wrapping:

  • forEach(function() {})
  • map(function() {})
  • then(function() {})
  • UMD/Browserify/Webpack definitions

Less-good candidates:

  • addEventListener('foo', function() {})
  • on('foo', function() {})
  • once('foo', function() {})
  • catch('foo', function() {}) (maybe?)

We can check for the function name as a hint to avoid the paren-wrapping, but it ought to be justified by a benchmark. Maybe a UI library that adds a lot of event listeners would be a good test case for this.

@nolanlawson
Copy link
Owner Author

Another potential improvement: only apply the function-passed-to-function heuristic at the top level, because that's usually where we find large IIFEs-that-don't-look-like-IIFEs.

@krisselden
Copy link
Collaborator

@nolanlawson define( in an app should not be made eager or the app is likely to get slower.

nolanlawson added a commit that referenced this issue Sep 20, 2016
@nolanlawson
Copy link
Owner Author

I thought in RequireJS the defined module is executed immediately? needs to check RequireJS output

@krisselden
Copy link
Collaborator

It is executed when it is required and only if it is required. Unfortunately our app defines a lot of modules that it does not use right away and some that it does.

@krisselden
Copy link
Collaborator

define is both the best candidate and worse but needs to know what the core modules of an app are, what gets used by most routes/states of the app. The focus of this has been libraries, which is a good place to start, in our app it would likely give it a decent boost but only if applied to some of our defines.

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

No branches or pull requests

2 participants