To embed or to not embed?

My site has a very small amount of JavaScript. This snippet infact is the entirety of my JavaScript:
(document.getElementById("theme-button").onclick = () => {
    const theme = localStorage.getItem("theme") === "light"
        ? "dark" : "light";
    localStorage.setItem("theme", theme);
    document
        .getElementsByTagName("html")[0]
        .setAttribute("data-theme", theme);
})();

Now as a non-webdev, does it make sense performance-wise to embed this in a <script> tag in my HTML? Or can I put this in an external script file that I load in via <script src=>? I would hope that with browser caching the latter would have zero performance impact after the initial load, but I am not really sure.
Was this page helpful?