{"id":13463260,"url":"https://github.com/lautis/uglifier","last_synced_at":"2025-10-03T15:18:37.374Z","repository":{"id":47156923,"uuid":"1049182","full_name":"lautis/uglifier","owner":"lautis","description":"Ruby wrapper for UglifyJS JavaScript compressor.","archived":false,"fork":false,"pushed_at":"2024-09-22T10:00:25.000Z","size":1822,"stargazers_count":620,"open_issues_count":48,"forks_count":85,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-18T14:09:40.999Z","etag":null,"topics":["javascript","minify","ruby","uglifyjs"],"latest_commit_sha":null,"homepage":"http://www.rubydoc.info/gems/uglifier","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lautis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2010-11-03T20:56:15.000Z","updated_at":"2025-04-13T22:27:42.000Z","dependencies_parsed_at":"2024-01-13T01:46:42.386Z","dependency_job_id":"d66193f7-c170-4209-87a3-a05b77bc45d2","html_url":"https://github.com/lautis/uglifier","commit_stats":{"total_commits":616,"total_committers":36,"mean_commits":17.11111111111111,"dds":"0.10227272727272729","last_synced_commit":"959b74053c8141445205d3c5c7c21821a7c02222"},"previous_names":[],"tags_count":95,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lautis%2Fuglifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lautis%2Fuglifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lautis%2Fuglifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lautis%2Fuglifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lautis","download_url":"https://codeload.github.com/lautis/uglifier/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249590053,"owners_count":21296146,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","minify","ruby","uglifyjs"],"created_at":"2024-07-31T13:00:49.196Z","updated_at":"2025-10-03T15:18:32.328Z","avatar_url":"https://github.com/lautis.png","language":"JavaScript","readme":"# Uglifier\n\nRuby wrapper for [UglifyJS](https://github.com/mishoo/UglifyJS2) JavaScript\ncompressor.\n\nUglifyJS only works with ES5. If you need to compress ES6, [ruby-terser](https://github.com/ahorek/terser-ruby) is a better option.\n\n### Rails\n\nWhen used in Rails, replace\n\n```ruby\nconfig.assets.js_compressor = :uglifier\n```\n\nwith\n\n```ruby\nconfig.assets.js_compressor = Uglifier.new(harmony: true)\n```\n\nin `config/environments/production.rb`.\n\n## Installation\n\nUglifier is available as a ruby gem.\n\n    $ gem install uglifier\n\nEnsure that your environment has a JavaScript interpreter supported by\n[ExecJS](https://github.com/rails/execjs). Using `therubyracer` gem\nis a safe choice if a runtime isn't already present. Note that while JScript built-in Windows 7 and older works, it is extremely slow.\n\n## Usage\n\n```ruby\nrequire 'uglifier'\n\nUglifier.new.compile(File.read(\"source.js\"))\n# =\u003e js file minified\n\n# Or alternatively\nUglifier.compile(File.read(\"source.js\"))\n```\n\nUglifier also supports generating source maps:\n\n```ruby\nuglified, source_map = Uglifier.new.compile_with_map(source)\n```\n\nWhen initializing UglifyJS, you can tune the behavior of UglifyJS by passing options. For example, if you want disable variable name mangling:\n\n```ruby\nUglifier.new(:mangle =\u003e false).compile(source)\n\n# Or\nUglifier.compile(source, :mangle =\u003e false)\n```\n\nAvailable options and their defaults are\n\n```ruby\n{\n  :output =\u003e {\n    :ascii_only =\u003e true,        # Escape non-ASCII characters\n    :comments =\u003e :copyright,    # Preserve comments (:all, :jsdoc, :copyright, :none, Regexp (see below))\n    :inline_script =\u003e false,    # Escape occurrences of \u003c/script in strings\n    :quote_keys =\u003e false,       # Quote keys in object literals\n    :max_line_len =\u003e 32 * 1024, # Maximum line length in minified code\n    :bracketize =\u003e false,       # Bracketize if, for, do, while or with statements, even if their body is a single statement\n    :semicolons =\u003e true,        # Separate statements with semicolons\n    :preserve_line =\u003e false,    # Preserve line numbers in outputs\n    :beautify =\u003e false,         # Beautify output\n    :indent_level =\u003e 4,         # Indent level in spaces\n    :indent_start =\u003e 0,         # Starting indent level\n    :width =\u003e 80,               # Specify line width when beautifier is used (only with beautifier)\n    :preamble =\u003e nil,           # Preamble for the generated JS file. Can be used to insert any code or comment.\n    :wrap_iife =\u003e false,        # Wrap IIFEs in parenthesis. Note: this disables the negate_iife compression option.\n    :shebang =\u003e true,           # Preserve shebang (#!) in preamble (shell scripts)\n    :quote_style =\u003e 0,          # Quote style, possible values :auto (default), :single, :double, :original\n    :keep_quoted_props =\u003e false # Keep quotes property names\n  },\n  :mangle =\u003e {\n    :eval =\u003e false,             # Mangle names when eval of when is used in scope\n    :reserved =\u003e [\"$super\"],    # Argument names to be excluded from mangling\n    :sort =\u003e false,             # Assign shorter names to most frequently used variables. Often results in bigger output after gzip.\n    :toplevel =\u003e false,         # Mangle names declared in the toplevel scope\n    :properties =\u003e false,       # Mangle property names\n    :keep_fnames =\u003e false       # Do not modify function names\n  },                            # Mangle variable and function names, set to false to skip mangling\n  :mangle_properties =\u003e {\n    :regex =\u003e nil,              # A regular expression to filter property names to be mangled\n    :ignore_quoted =\u003e false,    # Only mangle unquoted property names\n    :debug =\u003e false,            # Mangle names with the original name still present\n  },                            # Mangle property names, disabled by default\n  :compress =\u003e {\n    :sequences =\u003e true,         # Allow statements to be joined by commas\n    :properties =\u003e true,        # Rewrite property access using the dot notation\n    :dead_code =\u003e true,         # Remove unreachable code\n    :drop_debugger =\u003e true,     # Remove debugger; statements\n    :unsafe =\u003e false,           # Apply \"unsafe\" transformations\n    :unsafe_comps =\u003e false,     # Reverse \u003c and \u003c= to \u003e and \u003e= to allow improved compression. This might be unsafe when an at least one of two operands is an object with computed values due the use of methods like get, or valueOf. This could cause change in execution order after operands in the comparison are switching. Compression only works if both comparisons and unsafe_comps are both set to true.\n    :unsafe_math =\u003e false,      # Optimize numerical expressions like 2 * x * 3 into 6 * x, which may give imprecise floating point results.\n    :unsafe_proto =\u003e false,     # Optimize expressions like Array.prototype.slice.call(a) into [].slice.call(a)\n    :conditionals =\u003e true,      # Optimize for if-s and conditional expressions\n    :comparisons =\u003e true,       # Apply binary node optimizations for comparisons\n    :evaluate =\u003e true,          # Attempt to evaluate constant expressions\n    :booleans =\u003e true,          # Various optimizations to boolean contexts\n    :loops =\u003e true,             # Optimize loops when condition can be statically determined\n    :unused =\u003e true,            # Drop unreferenced functions and variables\n    :toplevel =\u003e false,         # Drop unreferenced top-level functions and variables\n    :top_retain =\u003e [],          # prevent specific toplevel functions and variables from `unused` removal\n    :hoist_funs =\u003e true,        # Hoist function declarations\n    :hoist_vars =\u003e false,       # Hoist var declarations\n    :if_return =\u003e true,         # Optimizations for if/return and if/continue\n    :join_vars =\u003e true,         # Join consecutive var statements\n    :collapse_vars =\u003e false,    # Collapse single-use var and const definitions when possible.\n    :reduce_funcs =\u003e false,     # Inline single-use functions as function expressions. Depends on reduce_vars.\n    :reduce_vars =\u003e false,      # Collapse variables assigned with and used as constant values.\n    :negate_iife =\u003e true,       # Negate immediately invoked function expressions to avoid extra parens\n    :pure_getters =\u003e false,     # Assume that object property access does not have any side-effects\n    :pure_funcs =\u003e nil,         # List of functions without side-effects. Can safely discard function calls when the result value is not used\n    :drop_console =\u003e false,     # Drop calls to console.* functions\n    :keep_fargs =\u003e false,       # Preserve unused function arguments\n    :keep_fnames =\u003e false,      # Do not drop names in function definitions\n    :passes =\u003e 1,               # Number of times to run compress. Raising the number of passes will increase compress time, but can produce slightly smaller code.\n    :keep_infinity =\u003e false,    # Prevent compression of Infinity to 1/0\n    :side_effects =\u003e true,      # Pass false to disable potentially dropping functions marked as \"pure\" using pure comment annotation. See UglifyJS documentation for details.\n    :switches =\u003e true,          # de-duplicate and remove unreachable switch branches\n  },                            # Apply transformations to code, set to false to skip\n  :parse =\u003e {\n    :bare_returns =\u003e false,     # Allow top-level return statements.\n    :expression =\u003e false,       # Parse a single expression, rather than a program (for parsing JSON).\n    :html5_comments =\u003e true,    # Ignore HTML5 comments in input\n    :shebang =\u003e true,           # support #!command as the first line\n    :strict =\u003e false\n  },\n  :define =\u003e {},                # Define values for symbol replacement\n  :enclose =\u003e false,            # Enclose in output function wrapper, define replacements as key-value pairs\n  :keep_fnames =\u003e false,        # Generate code safe for the poor souls relying on Function.prototype.name at run-time. Sets both compress and mangle keep_fanems to true.\n  :source_map =\u003e {\n    :map_url =\u003e false,          # Url for source mapping to be appended in minified source\n    :url =\u003e false,              # Url for original source to be appended in minified source\n    :sources_content =\u003e false,  # Include original source content in map\n    :filename =\u003e nil,           # The filename of the input file\n    :root =\u003e nil,               # The URL of the directory which contains :filename\n    :output_filename =\u003e nil,    # The filename or URL where the minified output can be found\n    :input_source_map =\u003e nil    # The contents of the source map describing the input\n  },\n  :error_context_lines =\u003e 8,    # How many context lines surrounding the error line. Env var ERROR_CONTEXT_LINES overrides this option\n  :harmony =\u003e false             # Enable ES6/Harmony mode (experimental). Disabling mangling and compressing is recommended with Harmony mode.\n}\n```\n\nWhen passing a regular expression to the output =\u003e comments option, be sure to pass a valid Ruby Regexp.\nThe beginning and ending of comments are removed and cannot be matched (/*, */, //). For example:\nWhen matching\n\n```\n/*!\n * comment\n */\n```\n\nuse `Uglifier.new(output: {comments: /^!/})`.\n\n## Development\n\nTests are run using\n\n    bundle exec rake\n\nSee [CONTRIBUTING](https://github.com/lautis/uglifier/blob/master/CONTRIBUTING.md) for details about working on and contributing to Uglifier.\n\n## Copyright\n\n© Ville Lautanala. Released under MIT license, see [LICENSE](https://github.com/lautis/uglifier/blob/master/LICENSE.txt) for details.\n","funding_links":[],"categories":["JavaScript"],"sub_categories":["JavaScript Tools"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flautis%2Fuglifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flautis%2Fuglifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flautis%2Fuglifier/lists"}