# Faster (and smaller) uploads in Discourse with Rust, WebAssembly and MozJPEG | Blog

**URL:** https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998
**Category:** Blog
**Created:** [July 13, 2021, 3:38pm UTC](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998 "2021-07-13T15:38:30Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [July 13, 2021, 3:38pm UTC](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998/1 "2021-07-13T15:38:31Z")

</div>

As of a few weeks ago, image uploads in Discourse are faster AND smaller thanks to a technique that compresses and optimizes the images clientside _before_ they are uploaded. This blog post will describe how this feature works and how we implemented it in Discourse.

* * *
This is a companion discussion topic for the original entry at [https://blog.discourse.org/2021/07/faster-user-uploads-on-discourse-with-rust-webassembly-and-mozjpeg/](https://blog.discourse.org/2021/07/faster-user-uploads-on-discourse-with-rust-webassembly-and-mozjpeg/)

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [July 13, 2021, 4:12pm UTC](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998/2 "2021-07-13T16:12:23Z")

</div>

Amazing! 😍 This is an incredible improvement. Really great work. It’s so much more fun to upload and share photos in discussions now.

And an added benefit - people on slow connections are going to be able to upload a bunch of photos at a time now without the dreaded “Uploading…” appearing instead of the photo. 👍

---

<div class="post-metadata">

### Author: ![JimPas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jimpas/32/148179_2.png) [@JimPas](https://meta.discourse.org/u/JimPas)
#### Post date: [July 14, 2021, 2:38am UTC](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998/3 "2021-07-14T02:38:11Z")

</div>

Nice improvement… and Happy Birthday, Rafael!

---

<div class="post-metadata">

### Author: ![erlend\_sh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/erlend_sh/32/119475_2.png) [@erlend\_sh](https://meta.discourse.org/u/erlend_sh)
#### Post date: [July 14, 2021, 10:35pm UTC](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998/4 "2021-07-14T22:35:10Z")

</div>

Super psyched to see Discourse playing more with the power of Rust! 🦀 💪

[imageflow](https://github.com/imazen/imageflow) is another impressive Rust lib in this space.

I took the liberty of sharing the news here:

https://embed.reddit.com/r/rust/comments/okehky/faster_and_smaller_uploads_in_discourse_with_rust/?embed=true&ref_source=embed&ref=share

---

<div class="post-metadata">

### Author: ![TGP](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgp/32/153649_2.png) [@TGP](https://meta.discourse.org/u/TGP)
#### Post date: [July 16, 2021, 11:03pm UTC](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998/5 "2021-07-16T23:03:02Z")

</div>

This is something I have on my site right now? Meaning y’all shipped this level of improved functionality out to everyone just because you want a better product?

Part of me knows that’s true. I’ve been around enough to know how y’all roll, but damn. Part of me feels like I missed the part where this is an advanced optimization play.

---

<div class="post-metadata">

### Author: ![JimPas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jimpas/32/148179_2.png) [@JimPas](https://meta.discourse.org/u/JimPas)
#### Post date: [July 19, 2021, 6:29am UTC](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998/6 "2021-07-19T06:29:48Z")

</div>

> [@TGP](#):
>
> This is something I have on my site right now? Meaning y’all shipped this level of improved functionality out to everyone just because you want a better product?

Yes and yes. 😃

---

<div class="post-metadata">

### Author: ![TGP](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tgp/32/153649_2.png) [@TGP](https://meta.discourse.org/u/TGP)
#### Post date: [July 20, 2021, 2:28pm UTC](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998/7 "2021-07-20T14:28:54Z")

</div>

### _Freakin’ radical, man._

![Bill Murray Thank You GIF by filmeditor](https://global.discourse-cdn.com/meta/original/3X/f/5/f5b44c557347e1342af020957acfc0fad648a4db.webp)

---

<div class="post-metadata">

### Author: ![fuzzyk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fuzzyk/32/129208_2.png) [@fuzzyk](https://meta.discourse.org/u/fuzzyk)
#### Post date: [July 30, 2021, 6:05pm UTC](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998/8 "2021-07-30T18:05:35Z")

</div>

Getting lots of complaints from Android users about jumping cursors and degraded upload performance, unfortunately.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [July 30, 2021, 7:43pm UTC](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998/9 "2021-07-30T19:43:38Z")

</div>

> [@fuzzyk](#):
>
> jumping cursors

I have a PR open that will greatly improve the cursor/placeholder handling during multiple file uploads

[https://github.com/discourse/discourse/pull/13907](https://github.com/discourse/discourse/pull/13907)

> [@fuzzyk](#):
>
> degraded upload performance

If all of the following are true:

- You don’t care about storage costs
- Most of your user base has good internet upload
- Most of your audience browses from average or worse Android phones

You may want to either disable the feature or tweak the threshold for minimum size up a few megabytes.

---

<div class="post-metadata">

### Author: ![fuzzyk](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fuzzyk/32/129208_2.png) [@fuzzyk](https://meta.discourse.org/u/fuzzyk)
#### Post date: [July 30, 2021, 7:57pm UTC](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998/10 "2021-07-30T19:57:05Z")

</div>

> [@Falco](#):
>
> I have a PR open that will greatly improve the cursor/placeholder handling during multiple file uploads

That’s great to hear!

Sadly, many of my users have cheap-ish/older Android phones, so I won’t be re-enabling the feature any time soon. Haven’t had any problems myself on my iPhone 12.

---

<div class="post-metadata">

### Author: ![tobiaseigen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tobiaseigen/32/539204_2.png) [@tobiaseigen](https://meta.discourse.org/u/tobiaseigen)
#### Post date: [July 30, 2021, 8:01pm UTC](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998/11 "2021-07-30T20:01:56Z")

</div>

Falco, would it be possible or of interest to provide a user setting for this, so people who want it can choose to use it? Or an option to “use classic image uploader” as craigslist does it? Selecting that button toggles the upload method.

 ![Screen Shot 2021-07-30 at 1.00.05 PM](https://global.discourse-cdn.com/meta/original/3X/b/c/bccd7604a66c7b5bdc6948a7ee79dfb3440a44bf.png)

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [July 30, 2021, 8:05pm UTC](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998/12 "2021-07-30T20:05:05Z")

</div>

> [@fuzzyk](#):
>
> Sadly, many of my users have cheap-ish/older Android phones, so I won’t be re-enabling the feature any time soon. Haven’t had any problems myself on my iPhone 12.

Maybe tweak the minimum size for it, so it’s only triggers on file larger than 3MB, so old phones won’t reach it on their own camera pictures.

> [@tobiaseigen](#):
>
> would it be possible or of interest to provide a user setting for this

That was included in the [original RFC](https://meta.discourse.org/t/optional-image-optimization-before-upload/187656) but it was removed according to the comments received.

---

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [July 31, 2021, 11:30am UTC](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998/13 "2021-07-31T11:30:20Z")

</div>

Hi Rafael,

I think we have a little problem with the new placeholder handling. It seems the images goes inline not a new line. Not just on composer pre optimization but regular uploads too. Thanks 🙂

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [August 2, 2021, 6:44pm UTC](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998/14 "2021-08-02T18:44:10Z")

</div>

This should fix it

[https://github.com/discourse/discourse/pull/13917](https://github.com/discourse/discourse/pull/13917)

---

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [August 7, 2021, 5:47pm UTC](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998/15 "2021-08-07T17:47:04Z")

</div>

Hello Rafael,

Sorry I am late but tested just now. 😕 It works fine on multiple uploads if i drag images in new line but it seems the issue still there if drag image(s) the end of a text. Thank you 🙂

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [August 29, 2021, 8:26pm UTC](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998/16 "2021-08-29T20:26:14Z")

</div>

Is it all good now @Don?

---

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [August 30, 2021, 1:17am UTC](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998/17 "2021-08-30T01:17:07Z")

</div>

It seems to this one still happening.

> [@Don](#):
>
> it seems the issue still there if drag image(s) the end of a text.

---

<div class="post-metadata">

### Author: ![yhh9xdq7d](https://avatars.discourse-cdn.com/v4/letter/y/f0a364/32.png) [@yhh9xdq7d](https://meta.discourse.org/u/yhh9xdq7d)
#### Post date: [January 11, 2022, 9:00am UTC](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998/18 "2022-01-11T09:00:17Z")

</div>

Has this been fixed? @Falco

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [January 13, 2022, 5:49am UTC](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998/19 "2022-01-13T05:49:53Z")

</div>

Sorry, what is a bug in that video? That looks exactly as I would expect it to work?

---

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [January 13, 2022, 6:05am UTC](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998/20 "2022-01-13T06:05:23Z")

</div>

I missed this feature [A setting to always insert images as separate paragraphs - #16 by andrei](https://meta.discourse.org/t/a-setting-to-always-insert-images-as-separate-paragraphs/138769/16) which is I think works well until this commit [Faster (and smaller) uploads in Discourse with Rust, WebAssembly and MozJPEG | Blog - #9 by Falco](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998/9) not sure. 😕

I have a video from my community about this feature when I presented to the members.

[Next page](https://meta.discourse.org/t/faster-and-smaller-uploads-in-discourse-with-rust-webassembly-and-mozjpeg-blog/196998.md?page=2)
