discourse/public/javascripts
Rafael dos Santos Silva e5df5fe10b
FEATURE: Client-side JXL, HEIC, and animated GIF conversion (#39014)
## Summary

- Extends client-side image optimization to convert **JXL → JPEG**,
**HEIC → JPEG**, and **animated GIF → animated WEBP** using jSquash WASM
packages before upload
- Transparent JXL/HEIC images are converted to **WEBP** instead of JPEG,
so transparency is preserved (WEBP compresses much better than PNG for
this case)
- Gated as an **upcoming change** via
`composer_media_optimization_image_convert_enabled` (experimental,
`feature,all_members`, opt-in per group through the upcoming changes
admin UI)
- Sends raw file bytes to Web Worker for formats browsers can't decode
natively (JXL, HEIC), with new `"convert"` and `"convertAnimated"`
worker message types
- Adds JXL to `authorized_extensions` and `supported_images`; adds
HEIC/HEIF to `supported_images` for consistency
- Skips GIF→WEBP when output is larger than input
- Falls back to filename when MIME type is missing (browsers may not
recognize JXL/HEIC)

### Note on jSquash packages

This depends on Discourse-scoped forks of the jSquash packages
(`@discourse/jxl`, `@discourse/heic`, `@discourse/webp`,
`@discourse/gif`, `@discourse/jpeg`, `@discourse/resize`). The following
upstream PRs would let us move back to the canonical `@jsquash/*`
packages, but the upstream maintainer is currently unresponsive:

- https://github.com/jamsinclair/jSquash/pull/101 (`@jsquash/heic`)
- https://github.com/jamsinclair/jSquash/pull/103 (`@jsquash/webp`
animated support)
- https://github.com/jamsinclair/jSquash/pull/104 (`@jsquash/gif`)

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-11 12:02:50 -03:00
..
count.js
embed-topics.js FIX: The attribute is discourse-url not data-discourse-url 2020-10-28 17:12:29 -04:00
embed.js FIX: Use iframe style.height for embed resize messages (#39321) 2026-04-16 15:17:06 -03:00
media-optimization-worker.js FEATURE: Client-side JXL, HEIC, and animated GIF conversion (#39014) 2026-05-11 12:02:50 -03:00