Code Monkey home page Code Monkey logo

Comments (10)

nem035 avatar nem035 commented on May 4, 2024 2

@parkjs814 take a look at the sources here https://skalman.github.io/UglifyJS-online/
This person made a wrapper around uglify to make it run client-side.

from algorithm-visualizer.

64json avatar 64json commented on May 4, 2024 1

No worries about it :)
I have removed those dependencies while I implement multiple tracers.
Check out the dev branch. (I'm still working on it.)

from algorithm-visualizer.

64json avatar 64json commented on May 4, 2024 1

I figured out that we don't even need to use uglify.
I just moved all the global variables into an anonymous function, and changed all references to it.

fixed at ceadfa4

from algorithm-visualizer.

64json avatar 64json commented on May 4, 2024

Mhm, that can be a problem. Great point. In which way are you fixing this issue?

from algorithm-visualizer.

duaraghav8 avatar duaraghav8 commented on May 4, 2024

I'm a bit confused at this point. The simplest way is to use Watch points, but they are not suitable for production.
I'm also looking into this

The problem is that variables like codeEditor, dataEditor, etc. (who are susceptible) are global. So no matter where you execute eval() from, it WILL overwrite the variables of the same name.

from algorithm-visualizer.

64json avatar 64json commented on May 4, 2024

How do you think about uglifying the code internally before eval() it?
Then all the names of variables will have one or two letters, so that the global variables will not be overwritten.

from algorithm-visualizer.

duaraghav8 avatar duaraghav8 commented on May 4, 2024

You're right! we can do that.
But we can't uglify the variables tracer and G (in case of Graph algorithms) because these are then being used by script.js. We rely on eval () to create these 2 variables in the global scope so we can use them.
But otherwise it seems like a very good solution

from algorithm-visualizer.

64json avatar 64json commented on May 4, 2024

I was looking for uglifying library for the client side, but it seems most of them are for node.js.
Do you know any?

from algorithm-visualizer.

duaraghav8 avatar duaraghav8 commented on May 4, 2024

This seems fantastic. But its not solving the issue, i.e., all variable names remain intact even after the minification.

from algorithm-visualizer.

64json avatar 64json commented on May 4, 2024

That's not a big deal. We can just avoid short-named variables.
What I'm worrying about is that it could lower the performance of realtime-rendering.

from algorithm-visualizer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.