Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use batch processing to achieve css and js Image Compression

Shulou Source: shulou.com Published: 2022-06-03 08:18:11 11月15日 Update

This article mainly describes how to use batch processing to achieve css and js image compression, the text is very detailed, has a certain reference value, interested friends must read!

The code is as follows:

@echo off :: Set YUI Compressor startup directory SET YUIFOLDER=D:\yuicompressor-2.4.2\build\ :: Set your JS and CSS root directory, script will automatically find and compress all JS and CSS by tree hierarchy SET INFOLDER =D:\jscss\src SET OUTFOLDER=D:\jscss\build echo Looking for JavaScript, CSS... chdir /d %INFOLDER% for /r . %%a in (*.js *.css) do ( copy %%a "%OUTFOLDER%\" && echo copy %%~fa succeeded|| echo Failed to copy %%~fa, please check if the file exists! @echo is compressing %%~a... @java -jar %YUIFOLDER%\yuicompressor-2.4.2.jar --charset UTF-8%%~fa -o %%~fa ) @echo CSS JS compression complete! for /r . %%b in (*.gif) do ( @echo Looking for gif... @pngout %%~fb /kp del /q/f %%~fb ) @echo gif conversion complete! for /r . %%c in (*.png) do ( @echo Looking for png... @pngout %%~fc ) @echo png compression complete! pause & exit above is "how to use batch processing to achieve css and js image compression" all the content of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!

Tags: pictures content articles success code value interests guys partners levels documents more root directories directories knowledge scripts industry information information channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi NVidia Shulou Tech Info MariaDB Redmi