#egui #wasm #gamedev

egui_web

Bindings for compiling egui code to WASM for a web page

16 breaking releases

0.17.0 Feb 22, 2022
0.16.0 Dec 29, 2021
0.15.0 Oct 24, 2021
0.13.0 Jun 24, 2021
0.4.0 Nov 28, 2020

#1242 in Web programming

Download history 1160/week @ 2023-11-20 745/week @ 2023-11-27 655/week @ 2023-12-04 828/week @ 2023-12-11 1044/week @ 2023-12-18 602/week @ 2023-12-25 362/week @ 2024-01-01 911/week @ 2024-01-08 876/week @ 2024-01-15 705/week @ 2024-01-22 475/week @ 2024-01-29 704/week @ 2024-02-05 909/week @ 2024-02-12 1093/week @ 2024-02-19 1053/week @ 2024-02-26 1056/week @ 2024-03-04

4,301 downloads per month

MIT/Apache

1.5MB
27K SLoC

egui_web

Latest version Documentation unsafe forbidden MIT Apache

This crates allows you to compile GUI code written with egui to WASM to run on a web page.

Run the web demo to try it now.

Check out eframe_template for an example of how to set it up.

Downsides with using egui on the web

egui_web uses WebGL and WASM, and almost nothing else from the web tech stack. This has some benefits, but also produces some challanges and serious downsides.

  • Rendering: Getting pixel-perfect rendering right on the web is very difficult.
  • Search: you cannot search an egui web page like you would a normal web page.
  • Bringing up an on-screen keyboard on mobile: there is no JS function to do this, so egui_web fakes it by adding some invisible DOM elements. It doesn't always work.
  • Mobile text editing is not as good as for a normal web app.
  • Accessibility: There is an experimental screen reader for egui_web, but it has to be enabled explicitly. There is no JS function to ask "Does the user want a screen reader?" (and there should probably not be such a function, due to user tracking/integrity conserns).
  • No integration with browser settings for colors and fonts.
  • On Linux and Mac, Firefox will copy the WebGL render target from GPU, to CPU and then back again (https://bugzilla.mozilla.org/show_bug.cgi?id=1010527#c0), slowing down egui.

In many ways, egui_web is trying to make the browser do something it wasn't designed to do (though there are many things browser vendors could do to improve how well libraries like egui work).

The suggested use for egui_web are for web apps where performance and responsiveness are more important than accessability and mobile text editing.

Dependencies

~9–42MB
~600K SLoC