Vyvíjejte software pro zpracování HTML v Node.js Pomocí HTML Optimization API. Toto výkonné řešení Node.js vám pomůže bez námahy optimalizovat a zmenšit velikost souborů HTML. Otestujte možnosti komprese HTML online zdarma!
Zmenšit velké HTML soubory bez ztráty kvality. Odstraňte nepotřebná a nepoužívaná data. Zmenšete velikost HTML souboru v kódu. Knihovna JavaScript poskytuje vývojářům integrované API pro optimalizaci obsahu HTML.
JavaScript knihovna je samostatné řešení a nevyžaduje instalaci žádného softwaru třetích stran.
Bezeztrátová komprese a hluboká optimalizace obsahu usnadněná s 'Aspose.Words for Node.js via .NET'. Následující příklad ukazuje, jak optimalizovat obsah HTML souboru v JavaScript:
npm install @aspose/words
Kopírovat
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()) {
// Je na vývojáři, aby si vybral knihovnu pro kompresi obrazu.
const imageData = shape.getImageData().toStream();
// ...
// Komprimujte obrázek a nastavte jej zpět do tvaru.
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()) {
// Je na vývojáři, aby si vybral knihovnu pro kompresi obrazu.
const imageData = shape.getImageData().toStream();
// ...
// Komprimujte obrázek a nastavte jej zpět do tvaru.
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()) {
// Je na vývojáři, aby si vybral knihovnu pro kompresi obrazu.
const imageData = shape.getImageData().toStream();
// ...
// Komprimujte obrázek a nastavte jej zpět do tvaru.
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()) {
// Je na vývojáři, aby si vybral knihovnu pro kompresi obrazu.
const imageData = shape.getImageData().toStream();
// ...
// Komprimujte obrázek a nastavte jej zpět do tvaru.
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.
Můžete optimalizovat soubory v mnoha dalších formátech souborů: