Home Web Front-end JS Tutorial Introducing our Next-Generation JavaScript SDK

Introducing our Next-Generation JavaScript SDK

Dec 05, 2024 am 02:21 AM

Introducing our Next-Generation JavaScript SDK

By: Till Schneidereit

Today we’re happy to announce the availability of our brand-new JavaScript SDK. This SDK is a complete rewrite of our previous JavaScript SDK, with much improved ecosystem compatibility, standards compliance, robustness, and key new features.

This release also sets us on a path towards significant performance improvements and ongoing improvements to compatibility with existing JavaScript applications.

At the same time, we’re retaining a high degree of compatibility with the previous SDK, so upgrading should be straightforward for most users.

Let’s dive into more detail on what’s new and different about this release.

Building on the robust foundations of SpiderMonkey, StarlingMonkey, and ComponentizeJS

Where the previous SDK was built on top of the QuickJS JavaScript engine and the Javy runtime, the new SDK is built on top of the Firefox browser’s SpiderMonkey engine, and the Bytecode Alliance’s StarlingMonkey runtime and ComponentizeJS WIT bindings generator.

Together, these projects provide a fantastic foundation for our SDK:

  • SpiderMonkey is the JavaScript engine that powers the Firefox browser. It’s been in development for over 20 years, is used by millions of users every day, and can claim a degree of maturity that really only the big browser engines can.
  • StarlingMonkey is a JavaScript runtime we’ve built together with our friends at Fastly and contributed to the Bytecode Alliance. It’s built on top of SpiderMonkey in a highly modular way, making it easy to configure as needed for our use case. Crucially, it comes with an implementation of key web APIs that substantially improve compatibility with the web ecosystem, like the fetch API for handling outgoing HTTP requests, key parts of the Service Workers spec for handling incoming requests, streaming processing of request and response bodies using the web’s Streams API streamssetTimeout, and setInterval.
  • **ComponentizeJS **is a tool that enables using external interfaces defined in the WIT interface description language in JavaScript. That makes it easy to use not only the interfaces Spin provides in addition to what’s included in WASI, but also functionality implemented in other WebAssembly components, including ones written in other languages such as Rust, Go, Python, or C/C .

Radical Change Under the Hood, Small Tweaks on the Surface

As described above, the new implementation of our JS support could hardly be more different from the old one. The good news is that, thanks to the fact that JavaScript has an exceptionally robust specification, we can do all this without risking subtle breakage of existing code. While the new SDK comes with a slightly tweaked API that requires equally slight changes when upgrading existing projects, entirely replacing the underlying platform otherwise does not have any compatibility impact.

From there, they can then start taking advantage of the new features that the new SDK brings. Notably, we tweaked the API to make it easy to integrate streaming HTTP bodies without having to completely rewrite existing code.

New, standards based APIs

We implemented support for (a slightly tweaked version of) the existing APIs on top of the fetch API and Service Workers spec standards. Developers can choose to directly work with these standards if they prefer, giving them substantially improved compatibility with the broader web and JS ecosystem.

Standards help in a completely different way, too: since all of the HTTP support is now built using wasi-http, applications built with the new SDK that don’t make use of the Spin-specific APIs we also support can run in any environment that supports wasi-http, such as Wasmtime and Node.js (via JCO).

Just the beginning

With this release, we focused on changing the underlying platform for our JavaScript support in a drop-in compatible way, while already gaining support for modern web standards, composability with other WebAssembly components, and a more robust and mature foundation for future development.

Going forward, we’ll see rapid improvements in performance, compatibility, and new features. As a sneak peek, some of the most exciting developments in the works are:

  • Performance improvements: the Fastly team has been working on substantial performance improvements for JavaScript execution in WebAssembly. A first iteration of this work has just been integrated into StarlingMonkey and is already making execution several times faster, depending on the exact workload. This integration landed just yesterday and thus hasn’t been integrated into our JS SDK yet, but will be soon.
  • Improved compatibility with the web and JavaScript ecosystem: we’re close to landing a key improvement to StarlingMonkey: the ability to implement parts of the runtime itself, and of the web APIs it provides, in Rust instead of C . This will make it much easier to keep up with the latest developments in the web ecosystem, and to provide a more complete and compatible implementation of the web APIs that are crucial for compatibility with existing JavaScript applications. Not all JS code uses (web-)standards based API: a lot of code out there makes use of Node.js APIs. We’re working on providing a compatibility layer for these APIs, so that developers can use them in their Spin applications.
  • Support for more trigger types: currently, the new JavaScript SDK only supports HTTP triggers. We’re working on adding support for more trigger types, such as the Cron and Redis triggers. ## Stay In Touch We’re excited to be able to share this new SDK with you, and we’re looking forward to your feedback and contributions as we continue to improve it. Please join the chat in the Fermyon Discord server or our weekly project meetings, and follow us on X (formerly Twitter) @fermyontech and @spinframework!

The above is the detailed content of Introducing our Next-Generation JavaScript SDK. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1655
14
PHP Tutorial
1254
29
C# Tutorial
1228
24
Demystifying JavaScript: What It Does and Why It Matters Demystifying JavaScript: What It Does and Why It Matters Apr 09, 2025 am 12:07 AM

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

The Evolution of JavaScript: Current Trends and Future Prospects The Evolution of JavaScript: Current Trends and Future Prospects Apr 10, 2025 am 09:33 AM

The latest trends in JavaScript include the rise of TypeScript, the popularity of modern frameworks and libraries, and the application of WebAssembly. Future prospects cover more powerful type systems, the development of server-side JavaScript, the expansion of artificial intelligence and machine learning, and the potential of IoT and edge computing.

JavaScript Engines: Comparing Implementations JavaScript Engines: Comparing Implementations Apr 13, 2025 am 12:05 AM

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

JavaScript: Exploring the Versatility of a Web Language JavaScript: Exploring the Versatility of a Web Language Apr 11, 2025 am 12:01 AM

JavaScript is the core language of modern web development and is widely used for its diversity and flexibility. 1) Front-end development: build dynamic web pages and single-page applications through DOM operations and modern frameworks (such as React, Vue.js, Angular). 2) Server-side development: Node.js uses a non-blocking I/O model to handle high concurrency and real-time applications. 3) Mobile and desktop application development: cross-platform development is realized through ReactNative and Electron to improve development efficiency.

Python vs. JavaScript: The Learning Curve and Ease of Use Python vs. JavaScript: The Learning Curve and Ease of Use Apr 16, 2025 am 12:12 AM

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

How to Build a Multi-Tenant SaaS Application with Next.js (Frontend Integration) How to Build a Multi-Tenant SaaS Application with Next.js (Frontend Integration) Apr 11, 2025 am 08:22 AM

This article demonstrates frontend integration with a backend secured by Permit, building a functional EdTech SaaS application using Next.js. The frontend fetches user permissions to control UI visibility and ensures API requests adhere to role-base

From C/C   to JavaScript: How It All Works From C/C to JavaScript: How It All Works Apr 14, 2025 am 12:05 AM

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

How do I install JavaScript? How do I install JavaScript? Apr 05, 2025 am 12:16 AM

JavaScript does not require installation because it is already built into modern browsers. You just need a text editor and a browser to get started. 1) In the browser environment, run it by embedding the HTML file through tags. 2) In the Node.js environment, after downloading and installing Node.js, run the JavaScript file through the command line.

See all articles