diff --git a/tsweb/debug.go b/tsweb/debug.go
index ac1981999..4c0fabaff 100644
--- a/tsweb/debug.go
+++ b/tsweb/debug.go
@@ -9,7 +9,6 @@ import (
 	"html"
 	"io"
 	"net/http"
-	"net/http/pprof"
 	"net/url"
 	"os"
 	"runtime"
@@ -64,16 +63,7 @@ func Debugger(mux *http.ServeMux) *DebugHandler {
 		ret.Handle("varz", "Metrics (Prometheus)", http.HandlerFunc(varz.Handler))
 	}
 
-	// pprof.Index serves everything that runtime/pprof.Lookup finds:
-	// goroutine, threadcreate, heap, allocs, block, mutex
-	ret.Handle("pprof/", "pprof (index)", http.HandlerFunc(pprof.Index))
-	// But register the other ones from net/http/pprof directly:
-	ret.HandleSilent("pprof/cmdline", http.HandlerFunc(pprof.Cmdline))
-	ret.HandleSilent("pprof/profile", http.HandlerFunc(pprof.Profile))
-	ret.HandleSilent("pprof/symbol", http.HandlerFunc(pprof.Symbol))
-	ret.HandleSilent("pprof/trace", http.HandlerFunc(pprof.Trace))
-	ret.URL("/debug/pprof/goroutine?debug=1", "Goroutines (collapsed)")
-	ret.URL("/debug/pprof/goroutine?debug=2", "Goroutines (full)")
+	addProfilingHandlers(ret)
 	ret.Handle("gc", "force GC", http.HandlerFunc(gcHandler))
 	hostname, err := os.Hostname()
 	if err == nil {
diff --git a/tsweb/pprof_default.go b/tsweb/pprof_default.go
new file mode 100644
index 000000000..4fb417c0e
--- /dev/null
+++ b/tsweb/pprof_default.go
@@ -0,0 +1,24 @@
+// Copyright (c) Tailscale Inc & AUTHORS
+// SPDX-License-Identifier: BSD-3-Clause
+
+//go:build !js
+
+package tsweb
+
+import (
+	"net/http"
+	"net/http/pprof"
+)
+
+func addProfilingHandlers(d *DebugHandler) {
+	// pprof.Index serves everything that runtime/pprof.Lookup finds:
+	// goroutine, threadcreate, heap, allocs, block, mutex
+	d.Handle("pprof/", "pprof (index)", http.HandlerFunc(pprof.Index))
+	// But register the other ones from net/http/pprof directly:
+	d.HandleSilent("pprof/cmdline", http.HandlerFunc(pprof.Cmdline))
+	d.HandleSilent("pprof/profile", http.HandlerFunc(pprof.Profile))
+	d.HandleSilent("pprof/symbol", http.HandlerFunc(pprof.Symbol))
+	d.HandleSilent("pprof/trace", http.HandlerFunc(pprof.Trace))
+	d.URL("/debug/pprof/goroutine?debug=1", "Goroutines (collapsed)")
+	d.URL("/debug/pprof/goroutine?debug=2", "Goroutines (full)")
+}
diff --git a/tsweb/pprof_js.go b/tsweb/pprof_js.go
new file mode 100644
index 000000000..dedb5b9b4
--- /dev/null
+++ b/tsweb/pprof_js.go
@@ -0,0 +1,8 @@
+// Copyright (c) Tailscale Inc & AUTHORS
+// SPDX-License-Identifier: BSD-3-Clause
+
+package tsweb
+
+func addProfilingHandlers(d *DebugHandler) {
+	// No pprof in js builds, pprof doesn't work and bloats the build.
+}
diff --git a/tsweb/tsweb.go b/tsweb/tsweb.go
index 9ddb3fad5..119fed2e6 100644
--- a/tsweb/tsweb.go
+++ b/tsweb/tsweb.go
@@ -15,7 +15,6 @@ import (
 	"io"
 	"net"
 	"net/http"
-	_ "net/http/pprof"
 	"net/netip"
 	"net/url"
 	"os"