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

This book is 100% completeLast updated on 2026-07-30

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
135
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 more than 20 years of experience in software development, server infrastructure, cybersecurity, vulnerability research and reverse engineering. Throughout his career, he has designed, secured, analyzed and tested complex software and infrastructure, with a particular focus on understanding how systems fail and how they can be made more secure.

Outside of work, Steve enjoys sharing knowledge with the technology community. He collaborates with researchers, industry experts and technology professionals to write practical books covering software development, cybersecurity, cloud computing, networking, DevOps, artificial intelligence and enterprise technologies. His books focus on practical learning through clear explanations, real-world examples and hands-on exercises. With more than two decades of industry experience, his goal is to help IT professionals, students and technology enthusiasts build useful skills and stay current in a rapidly changing industry.

We believe readers deserve to know how our books are created. Most of our authors are not native English speakers, so we use AI to help translate, proofread manuscripts, fix grammar, improve sentence structure and make technical explanations easier to read. AI is used as an editing tool only. It does not replace the research, technical knowledge or hands-on experience behind our books. Some of our authors also prefer to remain anonymous for privacy or professional reasons. In those cases, we publish their work under a different name. The author's name may be different, but the quality of the content and our review process remain the same.

Every book is written, reviewed and maintained by experienced technology professionals, with contributions from our private technical community of more than 420 engineers and researchers. We spend far more time validating technical accuracy and keeping our content up to date than generating text. We are always interested in working with experienced professionals who have deep expertise in a particular technology or domain. If you would like to publish a book with us or help review an existing manuscript, we'd love to hear from you. Send us a message describing your area of expertise. We are especially interested in niche technologies, specialized skills and emerging topics that are underrepresented in existing technical literature.

If you look through the contents of our books, you'll see practical examples, detailed explanations and material that is regularly updated. Our goal is to publish books that professionals can actually rely on, not low-effort AI-generated content. If you ever feel that one of our books does not meet that standard, Leanpub offers a 60-day money-back guarantee. Feel free to request a refund if you are not satisfied with your purchase.

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.)

In fact, authors have earned over $15 million writing, publishing and selling 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