Sukurkite HTML apdorojimo programinę įrangą Node.js naudodami HTML Optimization API. Šis galingas Node.js sprendimas padeda be vargo optimizuoti ir sumažinti HTML failų dydį. Išbandykite HTML glaudinimo galimybes internete nemokamai!
Sumažinkite didelius HTML failus neprarandant kokybės. Ištrinkite nereikalingus ir nenaudojamus duomenis. HTML failo dydį kode. JavaScript biblioteka suteikia kūrėjams integruotą API, skirtą HTML turiniui optimizuoti.
JavaScript biblioteka yra atskiras sprendimas ir jai nereikia įdiegti jokios trečiosios šalies programinės įrangos.
Su 'Aspose.Words for Node.js via .NET' lengvas glaudinimas ir gilus turinio optimizavimas. Toliau pateiktame pavyzdyje parodyta, kaip optimizuoti HTML failo JavaScript:
npm install @aspose/words
Kopijuoti
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()) {
// Kūrėjas turi pasirinkti vaizdų glaudinimo biblioteką.
const imageData = shape.getImageData().toStream();
// ...
// Suspausti vaizdą ir nustatykite jį atgal į formą.
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()) {
// Kūrėjas turi pasirinkti vaizdų glaudinimo biblioteką.
const imageData = shape.getImageData().toStream();
// ...
// Suspausti vaizdą ir nustatykite jį atgal į formą.
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()) {
// Kūrėjas turi pasirinkti vaizdų glaudinimo biblioteką.
const imageData = shape.getImageData().toStream();
// ...
// Suspausti vaizdą ir nustatykite jį atgal į formą.
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()) {
// Kūrėjas turi pasirinkti vaizdų glaudinimo biblioteką.
const imageData = shape.getImageData().toStream();
// ...
// Suspausti vaizdą ir nustatykite jį atgal į formą.
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.
Galite optimizuoti daugelio kitų failų formatų failus: