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-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
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 T. Publications

Steve T. Publications is a specialized book publishing company dedicated to delivering high-quality technical resources for IT professionals, students, educators, and technology enthusiasts. Our mission is to make complex technology concepts accessible through well-structured, practical, and industry-relevant publications.

We focus on publishing books across a wide range of information technology disciplines, including software development, cloud computing, cybersecurity, artificial intelligence, data science, networking, DevOps, databases, and enterprise technologies. Every publication is designed to bridge the gap between theory and real-world application, helping readers build the skills needed to succeed in today's rapidly evolving digital landscape.

At Steve T. Publications, we collaborate with experienced industry experts, educators, and technology professionals to produce accurate, up-to-date, and engaging content. We are committed to maintaining the highest editorial standards while empowering learners and professionals with trusted technical knowledge.

Whether you're beginning your IT journey, preparing for professional certifications, or advancing your expertise in emerging technologies, Steve T. Publications is your trusted source for authoritative and practical technical books.

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