Fejleszteni HTML Feldolgozó Szoftver Node.js segítségével HTML Optimization API. Ez a hatékony Node.js megoldás segít optimalizálni és csökkenteni a HTML fájlok méretét könnyedén. Tesztelje a HTML tömörítési képességeit online ingyen!
Csökkentse a nagy HTML fájlokat minőségromlás nélkül. Törölje a felesleges és fel nem használt adatokat. Csökkentse a HTML fájl méretét a kódban. A JavaScript könyvtár integrált API t biztosít a fejlesztőknek a HTML tartalom optimalizálásához.
JavaScript könyvtár egy önálló megoldás, és nem igényel harmadik féltől származó szoftvert.
A veszteségmentes tömörítés és a mély tartalomoptimalizálás egyszerűbbé válik az 'Aspose.Words for Node.js via .NET'. A következő példa bemutatja, hogyan lehet optimalizálni egy HTML JavaScript:
npm install @aspose/words
Másolat
const aw = require('@aspose/words');
var doc = new aw.Document("Input.html");
doc.cleanup();
var shapes = doc.getChildNodes(aw.NodeType.Shape, true)
for (var shape of shapes) {
if (shape.hasImage()) {
// A fejlesztő feladata, hogy kiválassza a könyvtárat a képtömörítéshez.
const imageData = shape.getImageData().toStream();
// ...
// Tömörítse a képet, és állítsa vissza az alakra.
shape.getImageData().setImage(compressedImageBuffer);
}
}
doc.save("Output.html")
const aw = require('@aspose/words');
var doc = new aw.Document("Input.html");
doc.cleanup();
var shapes = doc.getChildNodes(aw.NodeType.Shape, true)
for (var shape of shapes) {
if (shape.hasImage()) {
// A fejlesztő feladata, hogy kiválassza a könyvtárat a képtömörítéshez.
const imageData = shape.getImageData().toStream();
// ...
// Tömörítse a képet, és állítsa vissza az alakra.
shape.getImageData().setImage(compressedImageBuffer);
}
}
var saveOptions = new aw.Saving.PdfSaveOptions()
saveOptions.cacheBackgroundGraphics = true
doc.save("Output.html", saveOptions)
const aw = require('@aspose/words');
var doc = new aw.Document("Input.html");
doc.cleanup();
var shapes = doc.getChildNodes(aw.NodeType.Shape, true)
for (var shape of shapes) {
if (shape.hasImage()) {
// A fejlesztő feladata, hogy kiválassza a könyvtárat a képtömörítéshez.
const imageData = shape.getImageData().toStream();
// ...
// Tömörítse a képet, és állítsa vissza az alakra.
shape.getImageData().setImage(compressedImageBuffer);
}
}
doc.save("Output.html")
const aw = require('@aspose/words');
var doc = new aw.Document("Input.html");
doc.cleanup();
var shapes = doc.getChildNodes(aw.NodeType.Shape, true)
for (var shape of shapes) {
if (shape.hasImage()) {
// A fejlesztő feladata, hogy kiválassza a könyvtárat a képtömörítéshez.
const imageData = shape.getImageData().toStream();
// ...
// Tömörítse a képet, és állítsa vissza az alakra.
shape.getImageData().setImage(compressedImageBuffer);
}
}
var saveOptions = new aw.Saving.OoxmlSaveOptions()
saveOptions.compressionLevel = aw.Saving.CompressionLevel.Maximum
doc.save("Output.html", saveOptions)
const aw = require('@aspose/words');
var doc = new aw.Document()
var builder = new aw.DocumentBuilder(doc)
shape = builder.insertImage("Input.html")
var saveOptions = new aw.Saving.ImageSaveOptions(aw.SaveFormat.Html)
shape.getShapeRenderer().save("Output.html", saveOptions)
We host our Node.js via .Net packages in NPM repositories. Please follow the step-by-step instructions on how to install "Aspose.Words for Node.js via .NET" to your developer environment.
This package is compatible with Node.js 14.17.0 or higher.
Számos más fájlformátumban is optimalizálhatja a fájlokat: