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

uniqueId function is whitespace-dependent in minified script #912

Closed
hughes opened this issue Dec 21, 2012 · 1 comment
Closed

uniqueId function is whitespace-dependent in minified script #912

hughes opened this issue Dec 21, 2012 · 1 comment

Comments

@hughes
Copy link

hughes commented Dec 21, 2012

The unminified uniqueId function contains:

var id = '' + (++idCounter);

This minifies to:

var t=""+ ++N;

It works as it is, but breaks if the spacing changes:

var t=""+++N; // error

I know, you're thinking "why would you change the spacing if it works as it is?" I noticed this issue because we bundle underscore-min.js in our site's aggregated javascript file, the generator of which strips whitespace.

I know our bundling script is not optimal if it's breaking stuff, but this is the only part of underscore-min.js that suffers because of it.

If the function read var id = (++idCounter) + ''; it would not suffer from this issue.

@caseywebdev
Copy link
Contributor

👍 Not for the sake of a broken minifier, but because it's easier to read var id = ++idCounter + ''

jashkenas added a commit that referenced this issue Dec 21, 2012
Fix #912 - reorder `id` assignment in `uniqueId`
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

3 participants