Last active
April 16, 2026 15:11
-
-
Save roachhd/7bfa522b3d9409fae2df to your computer and use it in GitHub Desktop.
script to set a different CSS sheet for each day of the week
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var dSS = { | |
| names: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], | |
| number: new Date().getDay(), | |
| link: document.createElement('link') | |
| } | |
| dSS.link.rel = "stylesheet"; | |
| dSS.link.type = "text/css"; | |
| dSS.link.href = dSS.names[ dSS.number ] + ".css"; | |
| document.getElementsByTagName('head')[0].appendChild( dSS.link ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script type="text/javascript"> | |
| <!-- | |
| dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; | |
| dayNumber = new Date().getDay(); | |
| document.writeln('<link rel="stylesheet" type="text/css" href="' + dayNames[dayNumber] + '.css">'); | |
| //--> | |
| </script> | |
| <noscript> | |
| <link rel="stylesheet" type="text/css" href="default.css"> | |
| </noscript> |
Using JavaScript to dynamically load different CSS files based on the day of the week is a clean idea. It keeps the logic lightweight and avoids unnecessary complexity in the main codebase.
This kind of modular thinking is really useful in web development, especially when building user-friendly interfaces where adaptability and smooth experience matter a lot—similar to how platforms like Senpai Stream focus on simple and responsive UI behavior.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👏