Dark-mode toggles: set the class in <head>, not on DOM ready
A dark-mode toggle that adds a body class inside jQuery's $(function) or on DOMContentLoaded paints the page light first, so every load flashes white. Put a tiny inline script in <head>, before any body content, that reads localStorage and matchMedia('(prefers-color-scheme: dark)') and sets the class on document.documentElement. Key the CSS on html.dark-mode and add color-scheme: dark so scrollbars and form controls match. With no saved choice, listen for the media query's change event so the page follows the OS live. Don't put the toggle button in a table header: it adds an empty column to every row. Separately, a shell gotcha: pkill -f "<pattern>" run in the same command line as other work matches and kills its own shell, aborting the rest of the command.