Leanpub Header

Skip to main content

LiteRT.js: High-Performance On-Device AI Inference in the Browser

The Definitive Guide to Running Machine Learning Models Locally with WebAssembly, WebGPU, and WebNN

LiteRT.js: High-Performance On-Device AI Inference in the Browser
This book is 100% completeLast updated on 2026-10-13

Run powerful AI models directly in the browser with no servers and no cloud dependencies. LiteRT.js teaches you how to build fast, private, and production-ready machine learning applications using WebAssembly, WebGPU, and WebNN, with practical examples and performance-focused techniques throughout.

Minimum price

$19.00

$29.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
137
Pages
About

About

About the Book

LiteRT.js represents a paradigm shift in web-based artificial intelligence. By bringing Google's native, cross-platform LiteRT runtime into the browser through WebAssembly, it enables production-grade, hardware-accelerated model inference without any server dependencies. This book provides the complete technical foundation and practical implementation patterns for intermediate to advanced JavaScript developers who want to run machine learning models directly in the user's browser. From understanding the architecture and mastering the API to building real-world applications in image classification, object detection, speech recognition, LLM chatbots, and beyond, every chapter builds toward production-ready implementations with detailed code examples, performance optimization strategies, and deployment guidance.

Author

About the Author

Steve Publications

Steve is a technology professional with over 20 years of experience in software development, server infrastructure, cybersecurity, vulnerability research and reverse engineering. He specializes in analyzing complex systems, identifying weaknesses and improving security.

Beyond his professional work, Steve collaborates with researchers and industry experts to create practical technical books covering software development, cybersecurity, cloud computing, DevOps, AI and enterprise technologies. His goal is to help IT professionals, students and enthusiasts develop practical skills through clear explanations, real-world examples and hands-on exercises.

At Steve Publications, we use AI to assist with translation, proofreading and editing but not to replace the research, technical expertise or hands-on experience behind our books. Some authors publish under pseudonyms for privacy or professional reasons.

Every book is written, reviewed and maintained by experienced professionals, supported by a private community of over 420 engineers and researchers. We prioritize technical accuracy, practical value and regularly updated content over mass-produced AI-generated text.

We welcome experienced professionals interested in writing or reviewing books, especially in specialized and emerging technology fields. If you'd like to contribute, contact us with your area of expertise.

We stand behind our work. If a book doesn't meet your expectations, Leanpub offers a 60-day money-back guarantee.

Contents

Table of Contents

The Definitive Guide to Running Machine Learning Models Locally with WebAssembly, WebGPU and WebNN

Introduction

  1. What This Book Covers
  2. What This Book Is Not
  3. How to Use This Book
  4. Prerequisites
  5. A Note on Versions

Chapter 1: The Web AI Revolution – Why LiteRT.js Matters

  1. The Browser as an AI Platform
  2. From TensorFlow.js to LiteRT.js: A Generational Shift
  3. What Is LiteRT? The Unified On-Device Runtime
  4. The Value Proposition: Privacy, Performance and Cost
  5. When to Use (and Not Use) LiteRT.js
  6. The Landscape of Browser AI

Chapter 2: Architecture Deep Dive

  1. The JS-to-WebAssembly Bridge Pattern
  2. Model Loading and Compilation Pipeline
  3. Tensor Buffer Management and Memory Layout
  4. Accelerator Delegation System
  5. SignatureRunner and Named Entry Points

Chapter 3: Getting Started – Installation, Initialization and First Inference

  1. Installing @litertjs/core
  2. Serving WebAssembly Binaries
  3. Runtime Initialization with loadLiteRt
  4. Loading and Compiling Your First Model
  5. Running Inference and Reading Results

Chapter 4: Hardware Acceleration – WebGPU, WebNN and XNNPACK

  1. WebGPU: GPU-Accelerated Inference
  2. WebNN: Neural Processing Unit Access
  3. XNNPack on WebAssembly: Optimized CPU Execution
  4. Accelerator Selection Strategy and Fallback Patterns
  5. JSPI (JavaScript Promise Integration) for Asynchronous Execution

Chapter 5: Model Conversion – From PyTorch, TensorFlow and JAX to .tflite

  1. The .tflite FlatBuffer Format
  2. Converting PyTorch Models with litert_torch
  3. Converting TensorFlow and JAX Models
  4. Ultralytics YOLO Export Integration
  5. Conversion Troubleshooting and Common Pitfalls

Chapter 6: Model Optimization – Quantization, Size Reduction and Performance Tuning

  1. Understanding Quantization: INT8, INT4, FP16
  2. Dynamic, Static and Weight-Only Quantization
  3. Using the AI Edge Quantizer
  4. Selective Quantization and Mixed-Precision Strategies
  5. Model Size vs. Accuracy Trade-offs

Chapter 7: The Complete API Reference

  1. Core Runtime Functions (loadLiteRt, loadAndCompile)
  2. Tensor Class: Creation, Manipulation and Transfer
  3. CompiledModel and SignatureRunner APIs
  4. Configuration Options and CompileOptions
  5. Error Handling and Debugging Utilities

Chapter 8: Memory Management and Performance Engineering

  1. Manual Memory Management: Why delete() Matters
  2. GPU-to-CPU Data Transfer Patterns
  3. Benchmarking Inference Performance
  4. Profiling and Diagnosing Bottlenecks
  5. Production Optimization Checklist

Chapter 9: Integration with Modern Web Frameworks

  1. React Integration (react-litert and Custom Hooks)
  2. Vue.js Composition API Integration
  3. Angular Services and Components
  4. Svelte Stores and Reactive Inference
  5. Next.js and Vite Build Configuration for WASM

Chapter 10: Computer Vision Applications

  1. Image Classification with MobileNet and ResNet
  2. Real-Time Object Detection with YOLO
  3. Semantic Segmentation Pipelines
  4. Depth Estimation and 3D Point Clouds
  5. Image Upscaling with Real-ESRGAN

Chapter 11: Audio, Speech, Text and Multimodal AI

  1. Audio Processing and Noise Suppression
  2. Speech Recognition Patterns in the Browser
  3. Text Embeddings and On-Device RAG
  4. OCR and Document Intelligence
  5. LLM Inference with LiteRT-LM.js

Chapter 12: Production Deployment – Security, Compatibility and Best Practices

  1. Security Model and Threat Considerations
  2. Browser Compatibility and Feature Detection
  3. Progressive Enhancement and Graceful Degradation
  4. Migrating from TensorFlow.js
  5. Production Deployment Checklist

Conclusion

References

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub