Back to blog

Follow and Subscribe

Replacing Client-side JavaScript SDKs with WebAssembly Components at the Edge

Alex Casalboni

Developer Advocate, Edgee

Terri Allegretto

Senior Manager, Product Marketing, Developer Platform

At Fastly, we're excited to highlight how Edgee is tackling a common developer challenge: performance issues from excessive client-side JavaScript. In this guest blog, Edgee explores how shifting third-party SDK logic, like analytics and A/B testing, from the browser to the edge using WebAssembly improves speed, security, and compliance. Powered by Fastly Compute, this approach offers a smarter, faster alternative to traditional JavaScript-heavy solutions.


Traditional web applications often rely on numerous JavaScript SDKs to integrate third-party services like analytics, personalization, and A/B testing. However, these SDKs slow down your website and introduce security vulnerabilities, compliance challenges, and data inconsistencies.

At Edgee, we are reinventing JavaScript SDKs by leveraging WebAssembly (Wasm) Components to offload these tasks to the edge. Before jumping to the solution, let’s take a closer look at the technical and business challenges.

The Challenge: Traditional client-side SDKs are flawed

Third-party JavaScript SDKs often lead to:​

  • Performance Degradation: Excessive scripts increase page load times and consume significant client resources.​

  • Security Risks: Third-party scripts can be vectors for supply chain attacks and other vulnerabilities.​

  • Privacy Concerns: SDKs often collect user data, complicating compliance with regulations like GDPR and CCPA.​

  • Data Inconsistencies: Ad blockers and tracking prevention tools can interfere with SDKs, leading to incomplete data collection.

By relying solely on client-side SDKs, web owners are left with an incomplete view of their websites and how visitors interact with them. Working with several media and SaaS industry leaders, Edgee found that organizations are missing out on up to 60% of the user interactions happening in the browser.

Because of these fundamental issues caused by client-side computation, the interactions never get recorded in the analytics tools, making it impossible for companies to analyze them properly. The result? Business decisions based on incomplete data and potentially misguided insights.

The Solution: WebAssembly Components at the Edge

Fastly Compute allows Edgee to run WebAssembly on a high-performance, globally distributed infrastructure – unlocking new capabilities previously impossible with traditional cloud or browser-based execution. Technically, the core of Edgee’s product is a Rust application that runs on Fastly Compute, acting as a reverse proxy in front of customers’ websites.

This allows Edgee to intercept all HTTP requests efficiently and implement custom request/response manipulation based on each customer’s configuration. Because Edgee sits in the critical request/response path, the proxy must run as quickly as possible, ideally within 5-10 milliseconds to minimize the overall response time. Thanks to Fastly’s global network, Edgee is handling billions of requests every month, with the compute logic running in less than five milliseconds at the 99th percentile.

On the Edgee managed service, you can create a new project and enable the Google Analytics component, set it up with your GA4 Measurement ID, and immediately start collecting pageviews and custom events at the edge. Similarly, you could one-click enable additional components for analytics, conversions tracking, or data warehousing - such as Google Analytics, Amplitude, Amazon S3, PostHog, Plausible, Segment, Meta, LinkedIn, Snapchat, and so on - without having to integrate new client-side or server-side SDKs.

By transforming SDKs into WebAssembly Components at the edge, you can achieve several benefits:​

  • Improved Performance: Reduced client-side processing, leading to faster page loads.​

  • Enhanced Security: Wasm's sandboxed execution model minimizes the attack surface compared to traditional scripts.​

  • Privacy Compliance: Processing data at the edge ensures better control over user information, aiding in regulatory compliance.​

  • Consistent Data Collection: Edge processing is less susceptible to client-side disruptions, ensuring more reliable data.​

None of this would be possible without the performance, flexibility, and developer-friendly capabilities of Fastly Compute. Fastly’s edge platform offers the low-latency, high-throughput environment required to make Edgee’s architecture scalable and reliable.

The Benefits of WebAssembly + Fastly

Fastly Compute provides the foundation of Edgee’s architecture with built-in WebAssembly support. WebAssembly allows Edgee to run a globally distributed and performant Rust application, while at the same time supporting a growing ecosystem of open source components to extend the platform for many use cases.

As a developer, you can push components to the Edgee Component Registry using any language compatible with WASI (preview 2), like Rust, Go, C, C#, JavaScript, TypeScript, and Python. Because Wasm support is slightly different for each language, we wanted to provide uniform tooling so developers don’t have to worry about the underlying Wasm complexity or figure out where to host them.

That’s why Edgee’s core project is an open source CLI that provides both reverse proxy capabilities and all the developer tooling needed to build, test, and push Wasm components, hiding most of the WASI/WIT complexity.

In practice, we define a set of domain-specific WIT interfaces, one for each component type. For example, you can create a Data Collection component by implementing the corresponding Data Collection world. The Edgee proxy also acts as a thin layer on top of Wasmtime and takes care of configuring and running components, supporting untrusted code thanks to Wasm secure sandboxing.

WebAssembly at the edge and in the cloud

Most of the data collection logic is asynchronous with respect to the critical path of the HTTP request, so the Edgee proxy can delegate it to an ad-hoc API, without waiting for the data collection results.

This ad-hoc API is called “Data Collection API” and it’s where all the Wasm components are executed. This part of the architecture acts as a Wasm(time) Host, instantiating Wasm components on the fly. We use several solutions for this API and for the most part it’s hosted on AWS Lambda.

Based on the incoming request, the Data Collection API takes care of dynamically downloading and instantiating Wasm components from the Edgee Component Registry. This process usually takes a few hundred milliseconds, and some additional latency is totally acceptable given the real-time requirements of the data collection pipeline.

Since the Data Collection API is running on Lambda and it’s already ingesting hundreds of events per second, there are always at least 10-20 warm runtimes. Each runtime is hot-loading the correct component version (as a .wasm file), instantiating it, and keeping it in memory for future invocations. The result is a managed fleet of Wasm Hosts. Each runtime hot-loads Wasm components on the fly and sends data to the correct destination in less than 100 milliseconds on average. And this happens across multiple regions to optimize resiliency and performance.

During the implementation of this API, we encountered a few interesting surprises. For example, with Python-based components. Because they require a full interpreter, they’re up to 300x larger than Rust components, resulting in much longer download and instantiation time. In some cases, this means multiple seconds of instantiation time for cold starts. We’re looking at ways to improve this, for example by serializing components into pre-instantiated Wasm files. Even though the file size tends to grow even larger, our early experiments with this approach show considerable improvements, speeding up instantiation time from almost 2 seconds to less than 2 milliseconds.

What’s next

The next step for Edgee is expanding the Component Registry with new component types, moving beyond analytics and data collection. Soon you’ll find new components for A/B testing, consent management, content personalization, security, and more.

We’re excited about our partnership with Fastly and look forward to learning from and contributing to the Wasm community, as well as finding new opportunities to integrate Fastly’s managed services, such as bot management, web application protection, and image optimization.