Technical & Processing Methodology
This document details the exact client-side pipeline executed when you convert or optimize an SVG on SVGtoWebP.online.
1. Strict XML Parsing & Security Sanitization
Uploaded files and pasted code are parsed using DOMParser(..., 'image/svg+xml') after stripping XML DOCTYPE/ENTITY declarations. A strict allowlist removes <script>, <foreignObject>, on* event attributes, javascript: URIs, and external http(s) resource links while preserving valid vector gradients, masks, clipPaths, and filters. Untrusted SVG is never injected via innerHTML.
2. Dimension Resolution & Fit Geometry
Intrinsic size is resolved from concrete CSS length attributes (px, pt, in, cm, mm) or proportional viewBox dimensions. Fit modes (contain, cover, fill, inside, outside) compute exact canvas dimensions and draw coordinates before rasterizing onto an off-DOM HTMLCanvasElement via a short-lived Blob URL.
3. Verified WebP Encoding (Lossy & True Lossless VP8L)
- Lossy Mode: Encodes via
canvas.toBlob('image/webp', quality)and inspects the output Blob MIME type and first 16 binary bytes (RIFF....WEBP). If a browser falls back to PNG, the engine lazily loads our self-hostedlibwebpWebAssembly module (@jsquash/webp) to guarantee valid WebP output. - Lossless Mode: Always loads
libwebpWASM withlossless: 1andexact: 1, producing and verifying a trueVP8Llossless WebP stream.
4. SVG Optimization & Batch ZIP Packaging
The SVG Optimizer lazily loads svgo/browser (v4), and batch exports lazily load JSZip with collision-safe unique filenames.