chrisdavies / eev

A tiny, fast, zero-dependency event emitter
522 stars 32 forks source link

Minified version not working #1

Closed soulchainer closed 8 years ago

soulchainer commented 8 years ago

I don't know if is only me, but the minified version doesn't work. It spills the

Uncaught SyntaxError: Unexpected token )

error just by loading it, in both, Firefox Developer Edition 47 and Chrome 50, at least. I had to minify this with ShrinkSafe to get a acceptable size and a working script.

Seems like UglifyJS breaks this particular (because generally it's my chosen one too) code with their «optimizations». And same happens with other alternatives, like Google Closure minifier.

chrisdavies commented 8 years ago

I updated the file /test/eev.html so that it loads eev.min.js. Can you pull master down locally and open that file and confirm that it shows the tests passing?

Are you running UglifyJS on the eev.min.js or on eev.js? I don't usually re-uglify .min files, and I'm not sure what the behavior would be in that situation.

soulchainer commented 8 years ago

It passes the tests, yes.

I think right now that probably I was doing something wrong or is a problem caused by the platform (Tumblr, don't judge me).

I just needed eev.min.js and I grabbed it manually from the repository and tried it. I'm not using a build system (this time), so I wasn't minifying anything myself (and I don't re-minify a minified script usually). But the minified version you have in the repository (that, according to the package.json should be minified with UglifyJS) wasn't working, so then I grabbed the eev.js and tried it unminified. And it worked. So, I imagined the problem was the minification, so I tried to minify it myself. First with UglifyJS → didn't work. Later with other minifiers, till I found one that worked :þ (the mentioned ShrinkSafe).

But now that I saw your tests passing correctly with the minified version, I tried it in a plunker... and it runs without errors. And tried just now in Fiddle and works all right. And tried in another Tumblr and... It breaks. So it must be something in Tumblr what is messing with the script minified that way... I should have tried that before, I don't know why I didn't do it: this isn't the first weird error Tumblr causes me.

I feel very sorry for wasting your time, man. My apologies :(.

chrisdavies commented 8 years ago

Hey, no worries. I would have done exactly the same in your shoes. Strange to hear that it doesn't work on Tumblr. I'd be interested to hear back from you if you ever can figure out why that is! Meanwhile, I'll close this.