Acceleration of my extensions (RUST or other ?)

Hello, i’m actually have an extension which is based on several js files, who do some verification on a website when we open it.

I actually want to rewrite these file when I read the exceptional speed gain that the anti brave ad had experienced due to the passage of its engine in RUST.

But i don’t have founded any documentation on how to develop extensions with rust by doing a duckduck search.

if it is impossible which language you recommend in order to gain performance/security in my extension.

thank you in advance

You can’t simply replace your JavaScript files with Rust and expect performance improvements :slight_smile:. Also you still need JavaScript to execute your WebAssembly code!

See the list of Use Cases for WebAssembly for browsers:
https://webassembly.org/docs/use-cases/

  • Better execution for languages and toolkits that are currently cross-compiled to the Web (C/C++, GWT, …).
  • Image / video editing.
  • Games:
    • Casual games that need to start quickly.
    • AAA games that have heavy assets.
    • Game portals (mixed-party/origin content).
  • Peer-to-peer applications (games, collaborative editing, decentralized and centralized).
  • Music applications (streaming, caching).
  • Image recognition.
  • Live video augmentation (e.g. putting hats on people’s heads).
  • VR and augmented reality (very low latency).
  • CAD applications.
  • Scientific visualization and simulation.
  • Interactive educational software, and news articles.
  • Platform simulation / emulation (ARC, DOSBox, QEMU, MAME, …).
  • Language interpreters and virtual machines.
  • POSIX user-space environment, allowing porting of existing POSIX applications.
  • Developer tooling (editors, compilers, debuggers, …).
  • Remote desktop.
  • VPN.
  • Encryption.
  • Local web server.
  • Common NPAPI users, within the web’s security model and APIs.
  • Fat client for enterprise applications (e.g. databases).

EDIT:
ok, you actually didn’t mentioned you wanted to use WebAssembly :slight_smile:, did I assumed correctly?

Also, if you are thinking about replacing your JavaScript with some other language, my ex-colleagues would tell you the Scala.js is the way to go, but I would say, go with TypeScript.

Thanks for you response, actualy your edit is true, i search the better language for rewrite my extension for having a easy way to obtimise it for have better performance (i have talked about rust because i have seen it’s better performance and easy optimisation, and js is not the easiest language for optimisation).

There is a disconnect here, I think.

Browsers run JavaScript or WebAssembly, and nothing else. So whatever you write has to be optimized for one of those two. WebAssembly can in theory be faster, but that primarily applies to specific uses right now, as far as I’m aware.

You can transpile almost any language to WebAssembly code (and generate bindings, or use a binding wrapper someone built for the language).

Whereas things like Scala or TypeScript and friends aren’t actually more efficient, they’re supersets (or in some cases subsets with extras) that offer you extra features like type checking.