Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/428.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 关于YUI压缩程序和Java脚本_Javascript_Yui Compressor - Fatal编程技术网

Javascript 关于YUI压缩程序和Java脚本

Javascript 关于YUI压缩程序和Java脚本,javascript,yui-compressor,Javascript,Yui Compressor,我在我的网站上使用把手。因此,我需要将“handlebar.runtime.js”发送到客户端。但是我发现Offsocial网站上的“handlebar.runtime.js”没有被压缩,所以我使用YUI压缩器来压缩它 当我检查压缩的“handlebar.runtime.js”时,发生了一些奇怪的事情:与前一个代码相比,一些代码在压缩的代码中消失了。压缩的一开始是这样的: /*! handlebars v1.3.0 Copyright (C) 2011 by Yehuda Katz

我在我的网站上使用把手。因此,我需要将“handlebar.runtime.js”发送到客户端。但是我发现Offsocial网站上的“handlebar.runtime.js”没有被压缩,所以我使用YUI压缩器来压缩它

当我检查压缩的“handlebar.runtime.js”时,发生了一些奇怪的事情:与前一个代码相比,一些代码在压缩的代码中消失了。压缩的一开始是这样的:

/*!

 handlebars v1.3.0

 Copyright (C) 2011 by Yehuda Katz

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.

 @license
 */
;var Handlebars=(function(){v (rest of the codes...)
/*!

handlebars v1.3.0

Copyright (C) 2011 by Yehuda Katz

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

@license
*/
/* exported Handlebars */
var Handlebars = (function() {
// handlebars/safe-string.js
var __module3__ = (function() {
"use strict";
var __exports__;
// Build out our basic SafeString type
function SafeString(string) {
this.string = string;
}

 SafeString.prototype.toString = function() {
  return "" + this.string;
 };

  __exports__ = SafeString;
  return __exports__;
})();
正如您所看到的,YUI压缩器并没有删除注释,代码的开头有一个奇怪的分号。有人能解释一下吗?谢谢

PS:开始未压缩的“handlebar.runtime.js”如下所示:

/*!

 handlebars v1.3.0

 Copyright (C) 2011 by Yehuda Katz

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in
 all copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.

 @license
 */
;var Handlebars=(function(){v (rest of the codes...)
/*!

handlebars v1.3.0

Copyright (C) 2011 by Yehuda Katz

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

@license
*/
/* exported Handlebars */
var Handlebars = (function() {
// handlebars/safe-string.js
var __module3__ = (function() {
"use strict";
var __exports__;
// Build out our basic SafeString type
function SafeString(string) {
this.string = string;
}

 SafeString.prototype.toString = function() {
  return "" + this.string;
 };

  __exports__ = SafeString;
  return __exports__;
})();

它仍然存在,因为起始注释
/*中有感叹号


正如使用开源库时通常所做的那样,您希望保留版权说明

,但您能否解释一下为什么一开始出现了一个奇怪的分号,并且与前一个分号相比,某些内容发生了变化?YUI compressor是否在压缩代码时更改脚本的内容?是YUI compressor优化内容以缩小文件大小。您可以使用命令行中的
--disable optimizations
选项禁用此功能。(见附件)。不完全确定额外的半专栏来自哪里,你能编辑你的帖子并添加非压缩版本的脚本吗?请看编辑后的问题,我添加了未压缩的一个开头。我找不到任何相关文档,但我猜这是一个预期行为,因此,当存在不可压缩的注释(由
/*!
定义)时,会添加半列,以防止放置在该注释之前的任何代码与注释后面的行合并。那么您的意思是分号对代码的功能没有影响?