Knowledge

Minification (programming)

Source ๐Ÿ“

374:(CSS) resources may be minified, preserving their behavior while considerably reducing their file size. Libraries available online are capable of minification and optimization to varying degrees. Some libraries also merge multiple script files into a single file for client download. JavaScript source maps can make code readable and debuggable even after it has been combined and minified. 72:, which are used to add readability to the code but are not required for it to execute. Minification reduces the size of the source code, making its transmission over a network (e.g. the Internet) more efficient. In programmer culture, aiming at extremely minified source code is the purpose of recreational 297:, which was superseded by UglifyJS2 in 2012; the rewrite was to allow for source map support. From 2017, Alex Lam took over maintenance and development of UglifyJS2, replacing it with UglifyJS3 which unified the CLI with the API. In 2018, 83:
in that the minified source can be interpreted immediately without the need for a decompression step: the same interpreter can work with both the original as well as with the minified source.
332:
The original format was created by Joseph Schorr as part of the Closure Inspector minification project. Version 2 and 3 of the format reduced the size of the map files considerably.
106:
or unminifier can only fully reverse the minification process if it is supplied details of the transformations done by such techniques. If not supplied those details, the reversed
566: 348:
comes with minification support for several languages. It can readily browse the Visual Studio Marketplace to download and install additional minifiers.
429: 444: 619: 593: 293:
which contained a source mapping feature together with a Firefox extension called Closure Inspector. In 2010, Mihai Bazon introduced
301:
has been forked from uglify-es and has gained momentum since; in 2020 it outstripped UglifyJS when measured in daily downloads.
367:
and websites have been developed to optimize file requests and reduce page load times by shrinking the size of various files.
392: 110:
will contain different variable names and control flow, even though it will have the same functionality as the original
570: 69: 421: 549: 529: 57: 20: 321:
to display different code to a user than the code actually executed by the computer. For example, to aid in
351:
JavaScript optimizers can minify and generate source maps. In addition certain online tools can compress
627: 94:
or unminifier. However, to achieve its goals, minification sometimes uses techniques also used by
352: 465: 371: 647: 49: 8: 652: 65: 345: 278: 80: 487: 404: 364: 285:, which removed comments and whitespace from JavaScript code. It was followed by 87: 56:
without changing its functionality. These unnecessary characters usually include
53: 641: 473: 400: 541: 16:
Removal of unnecessary characters in code without changing its functionality
449: 103: 91: 530:
https://github.com//terser/commit/3ef6879ecafd12b57e575ec85e6104e71d5a1b6f
326: 314: 111: 107: 99: 95: 45: 318: 123: 322: 73: 27: 325:
of minified code, by "mapping" this code to the original unminified
79:
Minification can be distinguished from the more general concept of
289:
in 2007. In 2009, Google opened up its Closure toolkit, including
61: 44:) is the process of removing all unnecessary characters from the 506:"terser ยท JavaScript mangler and compressor toolkit for ES6+" 98:; for example, shortening variable names and refactoring the 445:"Google opens up its JavaScript development toolbox to all" 86:
The goals of minification are not the same as the goals of
131:// This is a comment that will be removed by the minifier 594:"Minify CSS โ€“ CSS Minifying and Compression Explained" 505: 90:; the former is often intended to be reversed using a 26:"Terser" redirects here. For the basic topic, see 639: 102:. When minification uses such techniques, the 390: 620:"Introduction to JavaScript Source Maps" 391:Crockford, Douglas (11 September 2001). 640: 617: 591: 552:from the original on 27 January 2024. 463: 561: 559: 442: 416: 414: 432:from the original on 24 April 2016. 13: 358: 14: 664: 569:. 11 January 2011. Archived from 556: 466:"Should you switch to UglifyJS2?" 411: 304: 208:is equivalent to but longer than 50:interpreted programming languages 567:"Source Map Revision 3 Proposal" 464:Bazon, Mihai (8 November 2012). 393:"JSMin: The JavaScript Minifier" 611: 592:Megida, Dillion (18 May 2022). 585: 317:that allows software tools for 618:Seddon, Ryan (21 March 2012). 534: 523: 498: 480: 457: 443:Paul, Ryan (6 November 2009). 436: 384: 1: 377: 363:Components and libraries for 7: 428:. The WebPlatform Project. 10: 669: 272: 117: 25: 18: 340: 335: 210: 128: 58:white space characters 542:"Terser vs uglify-js" 426:webplatform.github.io 372:Cascading Style Sheet 630:on 28 December 2021. 19:For other uses, see 422:"Code minification" 62:new line characters 346:Visual Studio Code 279:Douglas Crockford 122:For example, the 660: 632: 631: 626:. Archived from 615: 609: 608: 606: 604: 589: 583: 582: 580: 578: 563: 554: 553: 538: 532: 527: 521: 520: 518: 516: 502: 496: 495: 484: 478: 477: 461: 455: 454: 440: 434: 433: 418: 409: 408: 407:on 5 April 2002. 403:. Archived from 388: 365:Web applications 291:Closure Compiler 268: 265: 262: 259: 256: 253: 250: 247: 244: 241: 238: 235: 232: 229: 226: 223: 220: 217: 214: 204: 201: 198: 195: 192: 189: 186: 183: 180: 177: 174: 171: 168: 165: 162: 159: 156: 153: 150: 147: 144: 141: 138: 135: 132: 81:data compression 70:block delimiters 68:, and sometimes 54:markup languages 668: 667: 663: 662: 661: 659: 658: 657: 638: 637: 636: 635: 616: 612: 602: 600: 590: 586: 576: 574: 573:on 8 March 2016 565: 564: 557: 540: 539: 535: 528: 524: 514: 512: 504: 503: 499: 488:"uglify-js NPM" 486: 485: 481: 462: 458: 441: 437: 420: 419: 412: 389: 385: 380: 370:JavaScript and 361: 359:Web development 343: 338: 307: 275: 270: 269: 266: 263: 260: 257: 254: 251: 248: 245: 242: 239: 236: 233: 230: 227: 224: 221: 218: 215: 212: 206: 205: 202: 199: 196: 193: 190: 187: 184: 181: 178: 175: 172: 169: 166: 163: 160: 157: 154: 151: 148: 145: 142: 139: 136: 133: 130: 120: 31: 24: 17: 12: 11: 5: 666: 656: 655: 650: 634: 633: 610: 598:Free Code Camp 584: 555: 533: 522: 497: 479: 474:Self-published 470:lisperator.net 456: 435: 410: 401:Self-published 382: 381: 379: 376: 360: 357: 342: 339: 337: 334: 306: 305:Source mapping 303: 287:YUI Compressor 274: 271: 211: 129: 119: 116: 104:pretty-printer 92:pretty-printer 76:competitions. 15: 9: 6: 4: 3: 2: 665: 654: 651: 649: 646: 645: 643: 629: 625: 621: 614: 599: 595: 588: 572: 568: 562: 560: 551: 547: 543: 537: 531: 526: 511: 507: 501: 494:. 6 May 2017. 493: 489: 483: 475: 471: 467: 460: 452: 451: 446: 439: 431: 427: 423: 417: 415: 406: 402: 398: 397:Crockford.com 394: 387: 383: 375: 373: 368: 366: 356: 354: 349: 347: 333: 330: 328: 324: 320: 316: 312: 302: 300: 296: 292: 288: 284: 280: 209: 127: 125: 115: 113: 109: 105: 101: 97: 93: 89: 84: 82: 77: 75: 71: 67: 63: 59: 55: 51: 47: 43: 39: 35: 29: 22: 628:the original 623: 613: 601:. Retrieved 597: 587: 575:. Retrieved 571:the original 545: 536: 525: 513:. Retrieved 509: 500: 491: 482: 469: 459: 450:Ars Technica 448: 438: 425: 405:the original 396: 386: 369: 362: 350: 344: 331: 310: 308: 298: 294: 290: 286: 282: 276: 207: 121: 85: 78: 42:minimization 41: 38:minimisation 37: 34:Minification 33: 32: 21:Minimisation 648:Source code 624:HTML5 Rocks 327:source code 315:file format 281:introduced 112:source code 108:source code 100:source code 96:obfuscation 88:obfuscation 46:source code 653:JavaScript 642:Categories 546:NPM trends 515:29 January 510:terser.org 378:References 319:JavaScript 311:Source Map 124:JavaScript 492:npmjs.com 329:instead. 323:debugging 74:code golf 28:terseness 603:29 March 577:16 April 550:Archived 430:Archived 295:UglifyJS 277:In 2001 66:comments 355:files. 273:History 118:Example 299:Terser 36:(also 341:Tools 336:Types 313:is a 283:JSMin 191:array 137:array 126:code 605:2024 579:2016 517:2023 246:< 170:< 353:CSS 219:var 213:for 152:var 146:for 134:var 52:or 48:of 40:or 644:: 622:. 596:. 558:^ 548:. 544:. 508:. 490:. 472:. 468:. 447:. 424:. 413:^ 399:. 395:. 309:A 267:); 264:++ 249:20 182:++ 173:20 114:. 64:, 60:, 607:. 581:. 519:. 476:. 453:. 261:i 258:= 255:a 252:; 243:i 240:; 237:0 234:= 231:i 228:, 225:= 222:a 216:( 203:} 200:; 197:i 194:= 188:{ 185:) 179:i 176:; 167:i 164:; 161:0 158:= 155:i 149:( 143:; 140:= 30:. 23:.

Index

Minimisation
terseness
source code
interpreted programming languages
markup languages
white space characters
new line characters
comments
block delimiters
code golf
data compression
obfuscation
pretty-printer
obfuscation
source code
pretty-printer
source code
source code
JavaScript
Douglas Crockford
file format
JavaScript
debugging
source code
Visual Studio Code
CSS
Web applications
Cascading Style Sheet
"JSMin: The JavaScript Minifier"
Self-published

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.

โ†‘