slimit icon indicating copy to clipboard operation
slimit copied to clipboard

Specify certain tokens that cannot be mangled

Open ddevault opened this issue 11 years ago • 6 comments

I get a significant improvement by mangling the JS, but there are a couple of special functions that cannot lose their names.

ddevault avatar Jan 10 '14 08:01 ddevault

What do you mean? Slimit should mangle only non-globally-accessible function names and variables. So functions that you don't want accessed will be mangled, you can just wrap in IIFE: http://benalman.com/news/2010/11/immediately-invoked-function-expression/

programmin1 avatar Jan 10 '14 15:01 programmin1

Ah, here's the thing. I'm using web workers. I'm moving the name of internal functions, as strings, between the UI and the worker.

ddevault avatar Jan 10 '14 17:01 ddevault

Sounds interesting. Can you provide an example?

programmin1 avatar Jan 11 '14 02:01 programmin1

Here's the worker in question (it's in CoffeeScript): https://github.com/MediaCrush/MediaCrush/blob/master/scripts/worker.coffee

The worker can post messages back with execute, which contains code to be executed on the UI thread: https://github.com/MediaCrush/MediaCrush/blob/master/scripts/home.coffee#L129

This is used, for example, here: https://github.com/MediaCrush/MediaCrush/blob/master/scripts/home.coffee#L217 to run a callback after the worker finishes computing a hash.

ddevault avatar Jan 11 '14 02:01 ddevault

Slimit minifies .coffee?

programmin1 avatar Jan 11 '14 02:01 programmin1

No, it's compiled before it's given to slimit. https://github.com/MediaCrush/MediaCrush/blob/master/app.py#L38

ddevault avatar Jan 11 '14 02:01 ddevault