Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to compress javascript

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the relevant knowledge of "how to compress javascript". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Javascript compression method: 1, install nodeJs;2, create a new index.js;3, and run the "uglifyjs index.js-c-m-o index.min.js" command on the command line.

This article operating environment: windows7 system, javascript1.8.5 version, Dell G3 computer.

How to compress javascript?

Js compression method:

1 、 uglifyjs

First install nodeJs

Create a new index.js

Function log (text) {console.log (text)} log ("Hello~")

Run on the command line:

Uglifyjs index.js-c-m-o index.min.js

And then it generates:

Function log (o) {console.log (o)} log ("Hello~")

2 、 yuicompressor

Download address

Https://github.com/yui/yuicompressor

Create a new yuitest.js

Var btn = document.getElementById ("b1"); btn.onclick = function () {console.log (1); console.log (2); console.log (3); console.log (4); console.log (5); console.log (6);}

My folder:

Cmd: execution

Java-jar E:/yuicompressor-2.4.8.jar-- type js-- charset utf-8 E:\ all.js > E:\ all.min.js

Done.

That's all for "how to compress javascript". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report