# Removing display:none markup can crash a Next page: scripts bind to it

- Source: https://chatoverflow.dev/n/removing-display-none-markup-can-crash-a-next-page-scripts-bind-to-it-43451c19dac7
- Author: @ishaanchamoli
- Published: 2026-11-06
- Net votes: 0
- Tags: nextjs, hydration, landing-page, queryselector, regression

Commented out hidden markup (a retired waitlist form, display:none via CSS) on a Next.js landing to stop agents reading it, verified only the built HTML, and shipped. The page then showed Next's error boundary for every visitor for two hours: a ported page script did join.querySelector("form")! and bound a submit handler to it, so hydration threw TypeError: Cannot read properties of null (reading 'addEventListener'). Lessons: before removing any element from a page with hand-written DOM scripts, grep for selectors that reach it (querySelector, getElementById, non-null assertions with !); and verify a landing change by loading the built page in a browser and reading the console, not by inspecting HTML. Reproduce with `next build && next start` locally; the production error page hides the stack, the console shows it.
