Historically, every interactive chart and data filter required sending a round-trip network request to a backend Python server. DuckDB-Wasm and Danfo.js revolutionize modern web development by executing high-speed SQL queries and DataFrame operations directly inside the client's browser via WebAssembly.
By shifting analytical computations from expensive cloud backend instances to client WebAssembly runtimes, organizations cut cloud compute bills to zero, provide 60 FPS interactive filtering, and enable complete offline data privacy.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>In-Browser Analytics with DuckDB-Wasm</title>
<script type="module">
import * as duckdb from 'https://cdn.jsdelivr.net/npm/@duckdb/duckdb-wasm@latest/+esm';
async function initDuckDB() {
// 1. Select optimal WebAssembly bundle
const JSDELIVR_BUNDLES = duckdb.getJsDelivrBundles();
const bundle = await duckdb.selectBundle(JSDELIVR_BUNDLES);
const worker = new Worker(bundle.mainWorker);
const logger = new duckdb.ConsoleLogger();
const db = new duckdb.AsyncDuckDB(logger, worker);
await db.instantiate(bundle.mainModule, bundle.pthreadWorker);
const conn = await db.connect();
console.log("DuckDB-Wasm initialized in client browser!");
// 2. Query remote Parquet file via HTTP Range Request
await conn.query(`
CREATE TABLE sales AS
SELECT * FROM 'https://raw.githubusercontent.com/plotly/datasets/master/2014_usa_states.csv'
`);
// 3. Execute analytical SQL aggregation instantly
const result = await conn.query(`
SELECT Postal, Population
FROM sales
WHERE Population > 5000000
ORDER BY Population DESC
`);
console.log("Browser Query Output:", result.toArray());
document.getElementById("output").innerText = JSON.stringify(result.toArray(), null, 2);
}
initDuckDB();
</script>
</head>
<body>
<h2>DuckDB-Wasm Client-Side SQL Execution</h2>
<pre id="output">Loading in-browser engine...</pre>
</body>
</html>
Frontend developers can write JavaScript that mirrors Pandas exactly: const df = new dfd.DataFrame(data); df.groupby(['tier']).col(['spend']).mean().print();. It empowers React and Vue apps with instant client-side data transformations.
Broaden your statistical analysis, Python data wrangling, and production engineering expertise:
Decide when to compute on client browsers vs backend REST endpoints.
Stream remote Parquet files directly into browser WebAssembly memory.
Render sub-second interactive charts directly from DuckDB-Wasm SQL.
Run full analytical SQL queries inside client-side JavaScript applications.