为什么JavaScript Compressors用单引号替换单引号? [英] Why JavaScript Compressors replace single quotes with double quotes?

查看:87
本文介绍了为什么JavaScript Compressors用单引号替换单引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

制作了一些书签,我尝试使用JavaScript压缩程序,例如 Google Closure编译器 YUI压缩器.但是,我没有使用它们,因为它们用双引号替换了每个单引号.我不能使用带有双引号的代码,因为我应该用双引号将代码括起来,例如:

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>

因此,我使用了 MinifyJavascript 来进行缩小.我想知道为什么其他缩小器替换了引号.替换引号不会缩小代码.编码样式对于缩小代码并不重要.那是什么原因呢?

So, I used MinifyJavascript for minifying. I wonder why other minifiers replace quotes. Replacing quotes doesn't minify codes. Coding style is not important for minified code. Then what is the reason for this?

推荐答案

在此答案中的纯粹猜测:

Pure speculation in this answer:

  • 加强样式的一致性.
  • 由于重复的字符序列,一致性在gzip压缩后会减小大小.

真的不能想到其他任何东西. 他们本可以选择单引号而不是双引号.

Can't really think of anything else. They could have chosen single quotes instead of double, though.

这篇关于为什么JavaScript Compressors用单引号替换单引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆