Mango Man
Mango Man
Explore posts from servers
KPCKevin Powell - Community
Created by Mango Man on 8/9/2024 in #front-end
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);
})();
(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.
49 replies
KPCKevin Powell - Community
Created by Mango Man on 7/29/2023 in #resources
Looking for an HTML preprocessor
I will be honest, I assumed this would be super easy to find, but alas it is not. What I am effectively looking for is an HTML preprocessor to take something that is less verbose than HTML and give me HTML, because writing HTML by hand is a pain. I don’t want dynamic pages (so I am not interested in variables or for loops or any of that stuff), and I don’t want to need to spin up a whole JavaScript script just to compile some static pages (looking at you Pug). Is there any tool where I can have foo.ext and just do compile foo.ext >foo.html?
32 replies
KPCKevin Powell - Community
Created by Mango Man on 7/29/2023 in #front-end
How can I make fonts actually work well together?
4 replies
KPCKevin Powell - Community
Created by Mango Man on 7/22/2023 in #front-end
List tabulation
11 replies
KPCKevin Powell - Community
Created by Mango Man on 7/22/2023 in #front-end
Aligning text both to the left and center
16 replies