search
HomeDevelopment ToolsVSCodeHow to compress js code in vscode

How to compress js code in vscode

Dec 12, 2019 pm 02:47 PM
jsvscode

How to compress js code in vscode

vscode压缩js代码的方法:

1、在拓展商店里搜索“minify”,安装,安装成功后点重新加载

2、使用:F1运行文件缩小器Minify压缩js代码。

使用Minify的方法介绍:

缩小您的js,css和html文件以节省传输带宽。直接调用每个缩小器,以允许传递设置:

JS: uglify -js v2.7.4

CSS: clean-css v3.4.21

HTML: html-minifier v3.2.2

使用F1 运行文件缩小器Minify。

包含Javascript和CSS文件的文件夹可以{dirname}.min.[css|js]使用F1 缩小为一个文件Minify Directory。可以为Javascript和CSS减少一个目录是可以接受的。

(可选)在已存在匹配的缩小文件(和/或目录)时,在保存时运行minify。启用您的用户或工作空间设置。设置默认值如下所示:

"minify.minifyExistingOnSave": false,"minify.js": {
	"mangle": true,
	"compress": {
		"sequences": true,
		"properties": true,
		"dead_code": true,
		"drop_debugger": true,
		"unsafe": false,
		"unsafe_comps": false,
		"conditionals": true,
		"comparisons": true,
		"evaluate": true,
		"booleans": true,
		"loops": true,
		"unused": true,
		"hoist_funs": true,
		"keep_fargs": true,
		"keep_fnames": false,
		"hoist_vars": false,
		"if_return": true,
		"join_vars": true,
		"collapse_vars": false,
		"reduce_vars": false,
		"side_effects": true,
		"pure_getters": false,
		"pure_funcs": null,
		"negate_iife": false,
		"drop_console": false,
		"passes": 1,
		"global_defs": {}
	},
	"output": {
		"ascii_only": false,
		"inline_script": false,
		"max_line_len": 32000,
		"braces": false,
		"semicolons": true,
		"comments": false,
		"shebang": true,
		"preamble": null,
		"quote_style": "best"
	}},"minify.css": {
	"advanced": true,
	"aggressiveMerging": true,
	"compatibility": "*",
	"inliner": {},
	"keepBreaks": false,
	"keepSpecialComments": "*",
	"mediaMerging": true,
	"processImport": true,
	"processImportFrom": ["all"],
	"rebase": true,
	"restructuring": true,
	"root": "${workspaceRoot}",
	"roundingPrecision": 2,
	"semanticMerging": false,
	"shorthandCompacting": true},"minify.html": {
	"caseSensitive": false,
	"collapseBooleanAttributes": true,
	"collapseWhitespace": true,
	"conservativeCollapse": false,
	"customAttrAssign": [],
	"customAttrCollapse": "",
	"customAttrSurround": [],
	"customEventAttributes": [ "^on[a-z]{3,}$" ],
	"decodeEntities": false,
	"html5": true,
	"ignoreCustomComments": [ "^!" ],
	"ignoreCustomFragments": ["<%[\\s\\S]*?%>", "<\\?[\\s\\S]*?\\?>"],
	"includeAutoGeneratedTags": true,
	"keepClosingSlash": false,
	"maxLineLength": false,
	"minifyCSS": true, //uses minify.css settings if true
	"minifyJS": true, //uses minify.js settings if true
	"minifyURLs": false,
	"preserveLineBreaks": false,
	"preventAttributesEscaping": false,
	"processConditionalComments": false,
	"processScripts": [],
	"quoteCharacter": "\"",
	"removeAttributeQuotes": false,
	"removeComments": false,
	"removeEmptyAttributes": false,
	"removeEmptyElements": false,
	"removeOptionalTags": false,
	"removeRedundantAttributes": false,
	"removeScriptTypeAttributes": false,
	"removeStyleLinkTypeAttributes": false,
	"sortAttributes": false,
	"sortClassName": false,
	"useShortDoctype": false}

minifiy.css.root接受“ ${workspaceRoot}/ some / path”定义内部@import绝对根。

由于html-minifier还采用了clean-css和uglify-js,设置minifyJS或minifyCSS以true意志嵌入你为那些minifiers自动提供的设置。如果要使用一些其他方法,可以提供自己的设置作为对象。

PHP中文网,有大量免费的vscode入门教程,欢迎大家学习!

The above is the detailed content of How to compress js code in vscode. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Visual Studio: The IDE for C#, C  , and MoreVisual Studio: The IDE for C#, C , and MoreApr 25, 2025 am 12:10 AM

VisualStudio (VS) is a powerful integrated development environment (IDE) developed by Microsoft, which supports multiple programming languages, such as C#, C, Python, etc. 1) It provides a rich set of features including code editing, debugging, versioning and testing. 2) VS processes code through powerful editors and debuggers, and supports advanced code analysis and reconstruction using Roslyn and Clang/MSVC compiler platforms. 3) Basic usage is like creating a C# console application, and advanced usage is like implementing polymorphism. 4) Common errors can be debugged by setting breakpoints, viewing output windows, and using instant windows. 5) Performance optimization suggestions include the use of asynchronous programming, code reconstruction and performance analysis.

Visual Studio: Code Compilation, Testing, and DeploymentVisual Studio: Code Compilation, Testing, and DeploymentApr 24, 2025 am 12:05 AM

In VisualStudio, the steps for compiling, testing and deploying the code are as follows: 1. Compiling: Use VisualStudio's compiler options to convert source code into executable files, supporting multiple languages ​​such as C#, C and Python. 2. Testing: Use built-in MSTest and NUnit to perform unit testing to improve code quality and reliability. 3. Deployment: Transfer applications from the development environment to the production environment through web deployment, Azure deployment, etc. to ensure security and performance.

Visual Studio: An Introduction to the Integrated Development Environment (IDE)Visual Studio: An Introduction to the Integrated Development Environment (IDE)Apr 23, 2025 am 12:02 AM

VisualStudioisMicrosoft'sflagshipIDE,supportingmultipleprogramminglanguagesandenhancingcodingefficiency.1)ItoffersfeatureslikeIntelliSenseforcodeprediction,multi-tabbedinterfaceforprojectmanagement,andtoolsfordebugging,refactoring,andversioncontrol.2

Visual Studio: Exploring the Free and Paid OfferingsVisual Studio: Exploring the Free and Paid OfferingsApr 22, 2025 am 12:09 AM

The main difference between the free and paid versions of VisualStudio is the richness of features and the service supported. The free version (Community) is suitable for individual developers and small teams, providing basic development tools; the paid version (Professional and Enterprise) provides advanced features such as advanced debugging and team collaboration tools, suitable for large projects and enterprise-level development.

Visual Studio Community Edition: The Free Option ExplainedVisual Studio Community Edition: The Free Option ExplainedApr 21, 2025 am 12:09 AM

VisualStudioCommunityEdition is a free IDE suitable for individual developers, small teams and educational institutions. 1) It provides functions such as code editing, debugging, testing and version control. 2) Based on the Roslyn compiler platform, it supports multiple programming languages ​​and integrates Git and TFVC. 3) Advanced features include unit testing, optimization suggestions include turning off unnecessary extensions and using a lightweight editor.

Visual Studio: Building Applications with EaseVisual Studio: Building Applications with EaseApr 20, 2025 am 12:09 AM

VisualStudio is an integrated development environment (IDE) developed by Microsoft, which supports a variety of programming languages, including C#, C, Python, etc. 1. It provides IntelliSense function to help write code quickly. 2. The debugger allows setting breakpoints, step-by-step code execution, and identifying problems. 3. For beginners, creating a simple console application is a great way to get started. 4. Advanced usage includes the application of design patterns such as project management and dependency injection. 5. Common errors can be solved step by step through debugging tools. 6. Performance optimization and best practices include code optimization, version control, code quality inspection and automated testing.

Visual Studio and VS Code: Understanding Their Key DifferencesVisual Studio and VS Code: Understanding Their Key DifferencesApr 19, 2025 am 12:16 AM

VisualStudio is suitable for large-scale projects and enterprise-level application development, while VSCode is suitable for rapid development and multilingual support. 1. VisualStudio provides a comprehensive IDE environment and supports Microsoft technology stack. 2.VSCode is a lightweight editor that emphasizes flexibility and scalability, and supports cross-platform.

Is Visual Studio Still Free? Understanding the AvailabilityIs Visual Studio Still Free? Understanding the AvailabilityApr 18, 2025 am 12:05 AM

Yes, some versions of VisualStudio are free. Specifically, VisualStudioCommunityEdition is free for individual developers, open source projects, academic research, and small organizations. However, there are also paid versions such as VisualStudioProfessional and Enterprise, suitable for large teams and enterprises, providing additional features.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor