Code Monkey home page Code Monkey logo

Comments (5)

lautis avatar lautis commented on May 26, 2024

Assuming there is a bug in Uglifier variable mangling, you can disable it with {mangle: false} configuration option. This leaves variable names intact resulting in slightly larger code size after gzip.

Uglifier should always return the same output with same input. However, there are few things that I'm aware of that could break the setup in similar ways as you've described.

If you're caching compiled files on deployment environments, updating Uglifier version can change the minified output. Similarly, any compiled .erb.js files might be cached even when Ruby code it is calling is changed. You could try bumping config.assets.version in your application.rb to invalidate asset cached.

You didn't mention if disabling Uglifier fixes the issue, i.e. are there any differences in compiled JS before minification. If you haven't already done so, it'd be help to deploy without minification and compare those files on different nodes.

from uglifier.

tanelsuurhans avatar tanelsuurhans commented on May 26, 2024

Unless you mean caching the asset files for the client browser, this is not the case because i can see files being re-generated on the server, and i was also comparing files pulled from the servers file system, not from the browser.

I took two different compressed javascript files, which I then "uncompressed" by reformatting it and then used diff to see what the changes are. They were all seemingly variable name differences.

I could try disabling mangling, but that would kind of defeat the purpose here, right?
I understand that uglifier should always return the same output with the same input, but for some reason this is not happening for me. It kind of seems like it's and environment thing, but my ruby, rubygems and uglifier gem versions match across environments.

from uglifier.

tanelsuurhans avatar tanelsuurhans commented on May 26, 2024

What does uglifier use as an underlying library though? I would try to check if the native libraries are at the same versions to rule that issue out.

from uglifier.

lautis avatar lautis commented on May 26, 2024

Uglifier uses UglifyJS2. This is embedded in Uglifier and as such the version should be same on all nodes.

When I talked about caches, I meant Sprockets caches, not browser. Sprockets caches partial assets and in some deployment setups these can be persisted over deployments. E.g. if you include two libraries in your application libraries, the compiled versions of these libraries may be stored there. By bumping config.assets.version you can ensure that no stale and caches are used.

Disabling mangling only affects one aspect of the minification. Newlines and redundant code are still removed. To isolate the issue, you should try to disable mangling and even Uglifier itself if clearing caches doesn't help.

from uglifier.

erichummel avatar erichummel commented on May 26, 2024

I had this same issue and ultimately determined that the one node that was generating a different asset hash was running a different version of rake. Ensuring that all nodes had the same version of rake (which in our setup is managed outside of the Gemfile) solved the problem for me.

from uglifier.

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.