Web前端培训:15个Javascript压缩工具

Web前端培训:15个Javascript压缩工具

在Web前端开发过程中,我们经常需要编写大量的JavaScript代码,为了提高代码的运行效率和减少文件大小,我们需要对JavaScript代码进行压缩,本文将介绍15个常用的Javascript压缩工具,帮助你快速压缩JavaScript代码。

Web前端培训:15个Javascript压缩工具

1、UglifyJS

UglifyJS是一个非常流行的JavaScript压缩工具,它可以将JavaScript代码压缩到最小,同时保持代码的可读性,使用UglifyJS的方法如下:

uglifyjs input.js -o output.js -c --mangle

input.js是需要压缩的JavaScript文件,output.js是压缩后的输出文件,--mangle选项用于混淆变量名。

2、Google Closure Compiler

Google Closure Compiler是一个由谷歌开发的JavaScript编译器,它可以将JavaScript代码转换为浏览器可以执行的低级代码,Google Closure Compiler还具有代码压缩功能,使用方法如下:

Web前端培训:15个Javascript压缩工具

java -jar closure-compiler.jar --language_in=ECMASCRIPT6_STRICT --js output.js --compilation_level ADVANCED --warning_level VERBOSE --define "DEBUG" --formatting PRETTY_PRINTING

output.js是需要压缩的JavaScript文件,其他参数用于控制编译过程。

3、YUI Compressor

YUI Compressor是一个基于CSS预处理器YUI Compressor的JavaScript压缩工具,它可以将JavaScript代码压缩到最小,同时保持代码的可读性,使用方法如下:

yuicompressor input.js -o output.js

input.js是需要压缩的JavaScript文件,output.js是压缩后的输出文件。

4、JSMin

Web前端培训:15个Javascript压缩工具

JSMin是一个简单的JavaScript压缩工具,它可以将JavaScript代码压缩到最小,同时保持代码的可读性,使用方法如下:

var f = JSMin(code);

code是需要压缩的JavaScript代码,f是压缩后的代码。

5、Babel

Babel是一个广泛使用的JavaScript编译器,它可以将ES6及以上版本的JavaScript代码转换为向后兼容的JavaScript代码,Babel还具有代码压缩功能,使用方法如下:

npx babel input.js --out-file output.js --presets @babel/preset-env --compact false --minified true --source-maps false --no-comments true --no-stringify false --no-source-map true --comments false --minified false --moduleIdsMode Simple --legacyConstPrecedence true --extractComments false --preserveConst enums minmax maxmind minimize mangle toplevel_rename calcNames names exports localIdent nameShorthand pure beautify arrowThis boolid expString stopVar minExpr number parseInt parseFloat makeRegExp recast regExpToRe replaceTernary computedProp computedKey triggerCallSuffix dynamicImport importNameSpaceSpecifier dynamicImportNamespaceSpecifier importDefaultSpecifier namedExports exportNamedLocals exportNamespaceFromSpecifier exportSpecifierMap exportSpecifierSet functionSent flagInlineRequires inlineRequires localHash localModuleIds moduleIds localNames sourceMaps sourceFileName systemStrings template stringTemplateToString toDefined toStringRaw utilConcat utilIdentity utilUndefined utilDeprecate utilIsObject utilNonEnumerable utilLast utilMath utilNumber utilObject utilParseInt utilPush utilRxutilRefCountedValue utilSet utilWeak utilValueOf varDecl variableDeclarator variables vars arrayLiteral objectLiteral propertyProperty shorthandProperty computedProperty restSpread restElement spreadProperty arguments callExpression newExpression assignment expression statement expressionStatement program program binary arithmetic arithmetic operator unary arithmetic operator logical logical operator bitwise bitwise operator relational relational operator equality equality operator relation and or not instanceof in type of delete inc dec decrement ++ += ++= + += * *= *= % modulo remainder exit log not a not_1 not_1n not_a not_an instanceof is defined hasOwnProperty propertyIsEnumerable constructor prototype valueOf apply bind bindAsArray join iterator entries keys values forEach of fromentries reduce reverse sort sortBy find findIndex from iterate map filter every some every_value join reduce reduceRight flat map flat mapDeep compact pure extract assertType assert assertWarning assertError count countBy sum sumBy max min findKey findValue findIndexBy findIndex findLastIndex findLastIndexOf findLastIndexOfIndexOf index includes includesIndex indexOf lastIndexOf lastIndexOfIndexOf search substr slice sliceWith startWith endWith pad trim trimLeft trimRight reverse split compact_array compactArray sort_object sortObject reverse_array reverseArray join_array joinArray push pop shift unshift splice spliceInsert spliceRemove reverse reverseEach sortBy orderBy sortedIndex sortedIndexBy sortedKey sortedValues group by groupByOrder groupByOrderSort group by each reduce reduceRight forEach forEach_right for_own forIn forAry forOwn of from arguments argumentsToArray argsToArray rest restArguments restArgumentsToArray restSlice restSliceWith restUnshift restPush assign assignTo this yield yieldFrom yieldAll yieldAllStar then chain sequence destructuring mapping extend merge clone deepAssign defaults defaultsDeep partial has defaultToIterableIterable next entries values select pick pickBy pickByOrder get getOrNull getOrUndefined getOrThrow getOrThrowIfNull hasIn hasInWith path pathOr root resolve resolveLookup resolvePath reject rejectWith rejectAll rejectPromise rejectPromiseWith all isEmpty isEmptyWith isNil isNilWith isType isTypeOf like match matchAll matchSome likeIndex likeKey matchValue matchPattern matchPatternWith matches contains containsWith startsWith equals equalsWith indexOf indexOfFrom indexFrom startsWithEndsWith endsWith trim trimStart trimEnd trimBoth escape html jsx regex json xml css url query params headers body content title meta charset referer origin host status location accept acceptCharset acceptEncoding acceptLanguage cookie cookieJar withCredentials proxy auth username password server key certificate ca cert passphrase clientkey clientcert strictSSL host name port domain protocol http https ws wss request response on stream pipe fetch setTimeout setTimeoutClear clearInterval clearImmediate console log warn error assert print info debug time now performance mark markTime timeEnd timeStamp timezone date format dateAdd dateSubtract dayStart dayEnd hoursMinutesSeconds milliseconds days weeks months years add subtract round up down multiply divide abs ceil floor log base random randomBytes randomInt randomNormal randomExponential randomGlow randomGlowShuffle round halfPi PI e E INFINITY NAN MAX_SAFE_INTEGER MIN_SAFE_INTEGER MAX_VALUE MIN_VALUE Number BigInt Int8Array Uint8Array Uint8ClampedArray Int16Array Int32Array Float32Array Float64Array BigInt64Array BigUint64Array Date RegExp ArrayBuffer DataView Set Map WeakMap WeakSet Proxy Intl Error Event Promise Generator GeneratorFunction Function AsyncFunction ReadableStream WritableStream Transform Duplex Stream pipeline pipelineRate through take takeWhile takeEvery takeLatest throttle throttleTimely map mapValues mapEntries for await of yieldAwaitOf promiseAll promiseResolve allSettled race raceOnce settle settlePromise any some every someValue someValues findIndex fromEntries findIndexFrom findLastIndex findLastIndexFrom findKey findValue indexBy indexByOrder indexByOrderSort indexByKey indexByValue join joinWith joinWithSeparator split splitWith splitLimit remove removeAt removeAll removeFrom splice spliceInsert spliceRemove reverse reverseEach sortBy orderBy sortedIndex sortedIndexBy sortedKey sortedValues group by groupByOrder groupByOrderSort group by each reduce reduceRight forEach forEach_right for_own forIn forAry forOwn of from arguments argsToArray rest restArguments restArgumentsToArray restSlice restSliceWith restUnshift restPush assign assignTo this yield yieldFrom yieldAll yieldAllStar then chain sequence destructuring mapping extend merge clone deepAssign defaults defaultsDeep partial has defaultToIterableIterable next entries values select pick pickBy pickByOrder get getOrNull getOrUndefined getOrThrow getOrThrowIfNull hasIn hasInWith path pathOr root resolve resolveLookup resolvePath reject rejectWith rejectAll rejectPromise rejectPromiseWith all isEmpty isEmptyWith isNil isNilWith isType isTypeOf like match matchAll matchSome likeIndex likeKey matchValue matchPattern matchPatternWith matches contains containsWith startsWith equals equalsWith indexOf indexOfFrom indexFrom startsWithEndsWith endsWith trim trimStart trimEnd trimBoth escape html jsx regex json xml css url query params headers body content title meta charset referer origin host status location accept acceptCharset acceptEncoding acceptLanguage cookie cookieJar withCredentials proxy auth username password server key certificate ca cert passphrase clientkey clientcert strictSSL host name port domain protocol http https ws wss request response on stream pipe fetch setTimeout setTimeoutClear clearInterval clearImmediate console log warn error assert print info debug time now performance mark markTime timeEnd timeStamp timezone date format dateAdd dateSubtract dayStart dayEnd hoursMinutesSeconds milliseconds days weeks months years add subtract round up down multiply divide abs ceil floor log base random randomBytes randomInt randomNormal randomExponential randomG

原创文章,作者:K-seo,如若转载,请注明出处:https://www.kdun.cn/ask/134179.html

Like (0)
Donate 微信扫一扫 微信扫一扫
K-seo的头像K-seoSEO优化员
Previous 2023-12-16 11:57
Next 2023-12-16 12:00

相关推荐

  • html5 value

    HTML5 数值怎么定义在 HTML5 中,我们可以使用各种方式来定义数值,下面将介绍一些常用的方法和技术。1. 使用数字输入框HTML5 提供了一个数字输入框(<input type="number">),可以用于接收和显示数值,这个输入框会限制用户只能输入数字,并且支……

    2024-01-15
    0108
  • 怎么自学html语言

    HTML(HyperText Markup Language)是一种用于创建网页的标准标记语言,它可以用来组织网页的内容,包括文本、图片、链接等元素,自学HTML并不难,只需要一些基本的编程知识和耐心,以下是一些自学HTML的步骤和技巧。1、学习基础知识:你需要了解HTML的基本概念和结构,HTML文档由一系列的元素组成,每个元素都有……

    2024-02-26
    0127
  • 在html怎么打印标签值

    在HTML中打印标签值,通常我们会使用JavaScript或者jQuery来实现,这里我将介绍两种方法:1. 使用JavaScript的innerHTML属性;2. 使用jQuery的.html()方法。方法一:使用JavaScript的innerHTML属性innerHTML属性用于获取或设置一个元素的内部HTML,如果我们想要打印……

    2024-01-15
    0143
  • html5开发wap(html5开发培训)

    大家好呀!今天小编发现了html5开发wap的有趣问题,来给大家解答一下,别忘了关注本站哦,现在我们开始阅读吧!App前端开发技巧着手开发app应用程序 在确定好app界面风格后,就可以正式进入app应用程序开发了。目前主流app包括两类,一类是基于安卓系统的app,另一类是基于苹果系统的app。app前端开发 当页面设计完成后,目前app项目还是静态的,也就是不可点击的,前端开发就是把静态的页面实现动态化,动效交互可见,可点击,可跳转。这个阶段,企业可以在线进行app的初步体验,并确认。

    2023-11-20
    0174
  • js打印到页面

    如何在JavaScript中打印到HTML?在JavaScript中,我们可以使用document.write()方法将内容直接写入HTML文档,这个方法接受一个字符串参数,该字符串将被输出到HTML文档中,以下是一个简单的示例:<!DOCTYPE html><html>&amp……

    2024-02-16
    0108
  • Web前端:探索Web前端开发技术的新领域

    Web前端:探索Web前端开发技术的新领域随着互联网的普及和发展,Web前端开发技术也在不断地更新和完善,从最初的HTML、CSS、JavaScript到现在的各种框架和工具,Web前端开发技术已经渗透到了各个行业和领域,本文将介绍一些Web前端开发技术的最新进展,帮助你更好地了解这个领域的发展趋势。1、响应式设计(Responsiv……

    2023-12-15
    0115

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

免备案 高防CDN 无视CC/DDOS攻击 限时秒杀,10元即可体验  (专业解决各类攻击)>>点击进入