简体   繁体   English

最小化JavaScript代码

[英]Minimize javascript code

I am only new to javascript. 我只是javascript新手。 I am using minify to minimize load time of CSS and JS files. 我正在使用minify来最小化CSS和JS文件的加载时间。 I also compress the javascript in my HTML document (functions) using jscompress I am wondering if it was possible to even minimize the functions? 我还使用jscompress压缩了HTML文档(函数)中的javascript,我想知道是否有可能最小化这些函数? I am running ajax updates so in my HTML document I don't want my linked PHP files listed. 我正在运行ajax更新,因此在我的HTML文档中,我不想列出链接的PHP文件。

Is there a way to minimize the function codes found in the HTML using minify or another alternative method to do this? 有没有办法使用minify或其他替代方法来最小化HTML中找到的功能代码? Thanks. 谢谢。

Yes, you can extract the javascript code found in your html pages into a separate file. 是的,您可以将在html页面中找到的javascript代码提取到一个单独的文件中。

Wherever you are referencing php code like this <?php echo var_name ?> or something of that sort, send that as parameters into the appropriate "functions" in the new js file. 无论在何处引用此类<?php echo var_name ?>类的php代码,或将此类参数作为参数发送到新js文件中的相应“函数”中。

Now, process this newly created js file through the compression library. 现在,通过压缩库处理这个新创建的js文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM