Usually, if plaintext is pressed, there must be depression routine. How does a JavaScript engine interpret minified pressed JavaScript scripts?
Does a JavaScript engine have built-in deminification algorithms?
Usually, if plaintext is pressed, there must be depression routine. How does a JavaScript engine interpret minified pressed JavaScript scripts?
Does a JavaScript engine have built-in deminification algorithms?
Share Improve this question edited Sep 12, 2023 at 15:07 Peter Mortensen 31.6k22 gold badges110 silver badges133 bronze badges asked May 25, 2011 at 18:28 DrStrangeLoveDrStrangeLove 11.6k16 gold badges63 silver badges73 bronze badges 1-
minification just shortens variable names, eliminates as much whitespace as possible, takes out ments, etc... Anything to make the JS smaller, but still be syntactically valid. Basically it'd take
var this_is_a_really_long_useless_var_name=0;
and turn it intovar x=0;
– Marc B Commented May 25, 2011 at 18:30
4 Answers
Reset to default 6It does not need to be depressed; minified code is still JavaScript. It’s just harder for humans to read.
First, you need to understand that there is a difference between minification and pression.
1. Minification does not press
Minification is the process of reducing JavaScript to as few bytes as possible, by removing extra whitespace, changing variable names to shorter ones, etc. The encoding and characters of the file remain the same. Since a minified file doesn't actually change the encoding or functionality, nothing is needed to convert a file back since nothing really changed.
2. Compression changes a file
When you press a file, say using gzip, you are re-encoding the data of a file or stream into a different encoding that takes up less space. It is in this instance where a depression routine is needed to translate the file back to its unpressed state. When unpressed, the file returns to its original state.
3. Browsers use a bination of pression and minifcation to achieve as small of a bandwidth footprint as possible.
What's great about minification and pression is that they are two separate processes that do two separate things, and they can be bined to deliver as small a file to the browser as possible. For example, the original jQuery source right now is well over 200 KB, but through minifcation and delivering the file pressed, it only takes ~30 KB of bandwidth to deliver to the browser.
Minified JavaScript code is still javascript. Think of it as removing the white space and renaming long variable to shorter variable.
Minified JavaScript is simply that same code, but abbreviated (e.g. var foobar = 2 may before var a=2;)
GZipped JavaScript files (and other static files) are genuinely pressed, and do indeed get depressed by the client machine before the engine uses them.
The browser will identify to the server that it can access zipped content by a header similar to
Accept-Encoding: gzip, deflate
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744711022a4589343.html
评论列表(0条)