我看到很多网站的js都是变成了一行。在eclipse里format一下,就可一变成漂亮的格式。那有什么软件可以把js变成一行的。

解决方案 »

  1.   

    js文件的空格占字节的.
    写成一行能缩小文件大小.文件越大效果越好.你用Eclipse,可以下载一个插件Aptana,安装完后
    工具栏多了一个选项:Scripts --->  Javascript  ----> Compact  
      

  2.   

    textarea + js 就能很简单滴实现
    L@_@K
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
      <title> new document </title>
      <meta name="generator" content="editplus" />
      <meta name="author" content="" />
      <meta name="keywords" content="" />
      <meta name="description" content="" />
     </head> <body>
      <textarea id="ttaInput" rows="10" cols="100">function helloWorld(sYourName)
    {
        alert("Hello, " + sYourName);
    }
    helloWorld("csdn");</textarea>
      <input type="button" id="btnJoin" value="Join Lines" />
     </body>
     <script type="text/javascript">
     <!--
    function $(sId)
    {
    return document.getElementById(sId);
    }
    String.prototype.trim = function() {
       return this.replace(/(^\s*)|(\s*$)/g, "");
    };$("btnJoin").onclick = function() {
    var oArea = $("ttaInput");
    var strArray = oArea.value.split("\r\n");
    if (strArray.length > 1)
    {
    for (var i in strArray)
    {
    strArray[i] = strArray[i].trim();
    }
    oArea.value = strArray.join("");
    eval(oArea.value);
    }
    };
     //-->
     </script>
    </html>