如何手动缩小网页上的JavaScript代码? [英] How to minify javascript code on a webpage manually ?

查看:122
本文介绍了如何手动缩小网页上的JavaScript代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Everyone,



我遇到网站加载时间问题,并且在许多网站测试网站上它说我需要缩小我的javascript以减少网站加载时间,我的网站 Amway Nutrilite网站平均加载时间得分为70+,任何人都可以建议缩小java脚本..只是我已经尝试了许多没有成功的插件..



我尝试了什么:



我试过多个wordpress插件但没有运气,错误信息似乎仍然存在..

Hello Everyone,

I am facing a problems with site loadtime, and on many Site test sites it says I need to minify my javascript to reduce site load time, my site Amway Nutrilite Site gets a score of 70+ on an average load time, could any one please advise on minification of java script.. Just an fyi I have already tried many plugins with no sucess..

What I have tried:

I have tried multiple wordpress plugins but no luck, the error message still seems to be there..

推荐答案

可能是这个链接可能有帮助你 -

缩小 - 是否有一个好的JavaScript缩小器? - 堆栈溢出 [ ^ ]



有简单的在线压缩器,如

[ ^ ]
May be this link might help you -
minify - Is there a good JavaScript minifier? - Stack Overflow[^]

There are simple online compressor like
[^]


引用:

它说我需要缩小我的javascript以减少网站加载时间,

it says I need to minify my javascript to reduce site load time,

我读你的问题的方式,我认为你正在传递在主JavaScript文件中,而不是名为 scriptname.min.js 的文件。在生产线中,始终发送缩小的JavaScript文件。



大多数库,jQuery,Angular等都提供了必须在生产中使用的库的缩小版本。如果您想要更改任何内容,实际代码仅供您修改和更新。所以我相信这是你的问题。



其次,如果您碰巧需要使用缩小工具,任何工具都可以使用,但如果您有1%的疑问,请不要自己创建。因为,它可能只是 overkill 。 :笑:



试试这个: JavaScript Minifier [ ^ ](Google搜索js minifier的第一个结果)。

The way I read your question, I think you are passing down the main JavaScript file instead of the one named as scriptname.min.js. In the production line, always send down the minified JavaScript file.

Most of the libraries, jQuery, Angular etc. provide a minified version of their library that has to be used in production. The actual code is just for you to modify and update if you want to change anything at all. So I believe this is the problem in your case.

Secondly, if you happen to require a minification tool, any tool can be useful but do not create one yourself if you are even 1% in doubt. Because, it can simply be overkill. :laugh:

Try this: JavaScript Minifier[^] (first result from Google search for "js minifier").

这篇关于如何手动缩小网页上的JavaScript代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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