minify

Reliable and convenient JavaScript minifier [closed]

删除回忆录丶 提交于 2019-12-10 17:28:44
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I occasionally write JavaScript code. I am interested in minifying it for better performance, but I don't plan to spend to much time

Why does Closure Compiler not shorten this?

霸气de小男生 提交于 2019-12-10 17:28:34
问题 I'm not sure whether this is just a bug or an intended feature. Basically, I have this tiny function (I now see end is colored blue here but this works just fine, if I rename it to something else I still have the issue): function f(a, b) { var start = Math.min(a, b); var end = Math.max(a, b); tb.selectionStart = start; tb.selectionEnd = end; }; When closure-compiling it, I get: function f(a,b){var c=Math.max(a,b);tb.selectionStart=Math.min(a,b);tb.selectionEnd=c}; However, why is

Limit line length with requirejs + uglify

旧街凉风 提交于 2019-12-10 14:54:10
问题 We're using requirejs.optimize(config) with uglify2 in our build scripts to minify our production JavaScript code. We want to limit the minified line length to about 80 chars, so that it will be easier to debug JavaScript errors even from the production code. (Most browsers only report the line number, not the column, in the onerror handler, so source maps do not help.) Uglify2 contains the max-line-len option in the beautifier options. I've tried many different combinations of the following

Minify and variable names

核能气质少年 提交于 2019-12-10 14:34:50
问题 I know that minification is responsible for removing: white space characters, new line characters, comments, and sometimes block delimiters. Not long ago I read it's also responsible for shorten variable names. But I always thought it's a part of obfuscation. Am I right? Or now minification libraries also include such functionality? 回答1: Well, since the objective of minification is to reduce the size of the code as much as possible, renaming variables is an effective way of doing just that. A

Is there a benefit to pack third-party JS & CSS libraries along with my project assets?

拟墨画扇 提交于 2019-12-10 13:43:35
问题 I want to start using minifying tools such as Minify, Uglify or Closure to speed up the loading of my pages. My project relies on several bulky libraries (jQuery, Bootstrap, ...). I'm considering two options: Option 1: use an official CDN Minify only my project files into one .css and one .js file Serve the (minified) major libraries from a renowned CDN This would look like this: <script src="(my cdn)/myproject.min.js"></script> <script src="(official cdn)/jquery.min.js"></script> <script src

AJAX/JSON API minification?

ⅰ亾dé卋堺 提交于 2019-12-10 11:46:26
问题 Many JSON / RESTful APIs have long and verbose key names that amount to most of the bytes making up the file. For example, from Twitter's REST API: "profile_sidebar_border_color": "DFDFDF", "profile_sidebar_fill_color": "F3F3F3", "profile_text_color": "333333", "profile_use_background_image": true, "default_profile": false, "default_profile_image": false, Doing this also requires that those names be used in the client files. For development this is nice, but for production it seems like it

Getting Sprockets to minify CSS/JS while not in a Rails/Rack app

百般思念 提交于 2019-12-10 11:07:37
问题 I'm trying to use Sprockets to combine and minify my JavaScript and CSS files outside of the Rails and Rack context. So far, I'm able to combine them into a single file, but now I'm trying to run the JS compressor and the CSS compressor on those files. I followed the Sprockets README's instructions (https://github.com/sstephenson/sprockets#minifying-assets), but I'm getting this error: NoMethodError: undefined method `compress' for :uglify:Symbol Here is my complete rakefile: require

gulp-uglify won't preserve files order

不羁岁月 提交于 2019-12-10 10:56:46
问题 When I use gulp-uglify to minify the Javascript files the order gets messed up. Lets say I have this task working as expected: var gulp = require('gulp'); var rename = require('gulp-rename'); var gp_concat = require('gulp-concat'); gulp.task('js', function() { gulp.src([ './public/bower_components/jquery/dist/jquery.min.js', './public/js/functions.js', ]) .pipe(gp_concat('combined.js')) .pipe(gulp.dest(path.js + '/dist')) }); Adding the uglify line to it changes the order of the jquery and

How to use minified javascript?

≡放荡痞女 提交于 2019-12-10 10:46:53
问题 I have a grunt tasks to concat and minify all my javascript files into one single file and the javascript file is in dist folder. "dist/<%= pkg.name %>.min.js'" "Gruntfile.js" module.exports = function (grunt) { grunt.initConfig({ pkg: grunt.file.readJSON("package.json"), concat: { options: { separator: ';' }, dist: { src: ['src/main/resources/app/js/**/*.js', 'src/main/resources/app/config/*.js', 'src/main/resources/app/app/js'], dest: 'dist/<%= pkg.name %>.js' } }, uglify: { options: {

Why JavaScript Compressors replace single quotes with double quotes?

旧时模样 提交于 2019-12-10 10:03:08
问题 Making some Bookmarklet, I tried to use JavaScript minifier like Google Closure Compiler or YUI Compressor. However, I didn't use these because they replace every single quotes with double quotes. I can't use a code which has double quotes, as I should enclose the code with double quotes like: <a href="javascript:alert('hello')">hello</a> So, I used MinifyJavascript for minifying. I wonder why other minifiers replace quotes. Replacing quotes doesn't minify codes. Coding style is not important