Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

JPEG XL decoder in JavaScript using WebAssembly (WASM)

License

NotificationsYou must be signed in to change notification settings

niutech/jxl.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a JPEG XL decoder in JavaScript using WebAssembly implementation from theSquoosh app running in Web Worker.

Usage

Just insert your JPEG XL images to your HTML document as usual:<img src="image.jxl" alt="..." width="..." height="..."> and append the minified JXL.js script to the<head> of your web page:

<script src="jxl.min.js"></script>

That's it!

You can enable/disable cache and choose target image type (JPEG/PNG/WebP) by editing config at the beginning ofjxl.js file.

How it works

JXL.js uses Mutation Observer to watch for<img> and<picture> tags being added to the DOM as well as CSS background images and it decodes them as they appear using WebAssembly decoder in Web Worker. Then the JPEG XL image data is transcoded into JPEG/PNG/WebP image and cached usingCache API for faster subsequent page views (you can delete cached images usingDev Tools). The transcoding is performed using Offscreen Canvas in Web Worker for jank-free performance, if available.

Multithread version

There is an experimental multithread version of JXL.js using 4 threads in Web Workers and WebAssembly SIMD operations, if available, based on thelibjxl wasm demo. Requires HTTPS as well asCross-Origin-Opener-Policy andCross-Origin-Embedder-Policy response headers (or the provided Service Worker script as a fallback).

Benchmark

Single-threadMulti-thread
test.jxl790 ms440 ms
test2.jxl830 ms590 ms

Tested on Microsoft Edge 108, average times, no cache.

License

© 2022 Jerzy Głowacki and Squoosh Developers under Apache 2.0 License.

About

JPEG XL decoder in JavaScript using WebAssembly (WASM)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp