


JavaScript analysis and compression tool JavaScript Analyser_javascript skills
The JSA compression process is divided into two steps
The first step is syntax compression, which is similar to Dojo ShrinkSafe, but safer and more effective.
The second step is text compression, currently using
Compression algorithm of JavaScript Compressor.
(http://dean.edwards.name/packer/ )
These can be set in the settings window.
By default, syntax compression is used first. When the file is larger than 1000 bytes and can still be compressed to 90% of the original size using text compression, text compression is used on the original basis.
The following is a script compression example to demonstrate the JSA syntax compression and optimization functions.
try {
//xxxx();
}
catch (e) {
yyyy();
function f1() {
}
}
finally {
zzzz();
}
function f2(var1) {
var var2 = 2;
var var3 = 3;
var withObject = {var2:-2}
with(withObject){
alert(var2);
}
}
Compressed results (formatted for easy reference):
zzzz();
function f2(A) {
var var2 = 2;
var B = 3;
var C = {var2:-2};
with (C) {
alert(var2);
}
}
Compression ratio comparison with other compression tools:
1. JavaScript Compressor(http:// dean.edwards.name/packer/)
Taking his own compression tool code as an example (v2.02), the size after packer compression is 7,428 bytes (comments removed).
And our compression tool can compress to 7,256 bytes
7256 / 7428 = 0.9768443726440496
2.Dojo ShrinkSafe (rough stuff, inefficient and dangerous, it is recommended that original users replace it quickly)
With his own framework source code as an example (v0.4.1):
His own compressed size is 149,518 bytes, but we can reduce it to 81,261 bytes after compression
81261 / 149518 = 0.5434864029748927
Safety Instructions:
1.JavaScript Compressor
Text-based compression, I haven’t looked into the logic in detail, but the possibility of problems with this kind of compression is very low. Our compression tool also uses its compression algorithm, which is used in JSI 1.1 a8 and
No abnormalities were found in the test of its integrated third-party class library. Moreover, the well-known framework JQuery is used, so I believe there will be no problems.
Additional (2007-03-12): Today I discovered that this tool has a bug when parsing JavaScript multi-line string syntax. However, this problem will no longer exist after JSA syntax compression.
2.Dojo ShrinkSafe Danger! ! ! ! !
Replace long local variable names with shorter names. This is an extremely unsafe compression tool. For example:
function(){
var withObject = {variable1:1}
var variable1 = 2;
with(withObject){
alert(variable1);
}
}
will be compressed into:
function(){
var _1={variable1:1};
var _2=2;
with(_1){
alert(_2);
}
}
This is obviously wrong. This garbage does not pay attention to some special syntax and dynamics of JavaScript.
The eval function, catch operation, and with statement are not processed in any way.
In comparison, JSA is currently the safest and most effective compression tool I know of.
JSA not only provides code compression function, but also can do formatting and script analysis.
The script analysis function can be used to view script information and find potential problems in the script.
For example, check which functions and variables are declared in the script.
Which external variables are used. etc. . .

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system.

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

Title: Analysis of the reasons and solutions for why the secondary directory of DreamWeaver CMS cannot be opened. Dreamweaver CMS (DedeCMS) is a powerful open source content management system that is widely used in the construction of various websites. However, sometimes during the process of building a website, you may encounter a situation where the secondary directory cannot be opened, which brings trouble to the normal operation of the website. In this article, we will analyze the possible reasons why the secondary directory cannot be opened and provide specific code examples to solve this problem. 1. Possible cause analysis: Pseudo-static rule configuration problem: during use

Introduction to the method of obtaining HTTP status code in JavaScript: In front-end development, we often need to deal with the interaction with the back-end interface, and HTTP status code is a very important part of it. Understanding and obtaining HTTP status codes helps us better handle the data returned by the interface. This article will introduce how to use JavaScript to obtain HTTP status codes and provide specific code examples. 1. What is HTTP status code? HTTP status code means that when the browser initiates a request to the server, the service

Title: Is Tencent’s main programming language Go: An in-depth analysis. As China’s leading technology company, Tencent has always attracted much attention in its choice of programming languages. In recent years, some people believe that Tencent mainly adopts Go as its main programming language. This article will conduct an in-depth analysis of whether Tencent's main programming language is Go, and give specific code examples to support this view. 1. Application of Go language in Tencent Go is an open source programming language developed by Google. Its efficiency, concurrency and simplicity are loved by many developers.

Analysis of the advantages and limitations of static positioning technology With the development of modern technology, positioning technology has become an indispensable part of our lives. As one of them, static positioning technology has its unique advantages and limitations. This article will conduct an in-depth analysis of static positioning technology to better understand its current application status and future development trends. First, let’s take a look at the advantages of static positioning technology. Static positioning technology achieves the determination of position information by observing, measuring and calculating the object to be positioned. Compared with other positioning technologies,
