A simple way to dynamically switch the css and js of a site
- To use the switcher, set up 'scripts' and 'styles' folders in the root directory.
- The 'scripts.js' file must be included in 'scripts' and the 'collect-themes.php' file in the root directory.
- For the dynamic CSS, ensure that the CSS name matches the corrosponding JS name (if required). Save the CSS in the 'styles' folder and the JS in the 'scripts' folder.
- The select will automatcially populate form the titles in the 'styles' folder.
- Follow the in-document comments in 'scripts.js' to make adjustments to the text and sorting.
- The switcher will remember the last loaded stylesheet on page refresh
- New visitors will be shown a random stylesheet
The example in index.php shows how 4 different style sheets can be dynamically loaded. They are numbered using words, which are displayed alphabetically (editable in 'scripts.js'). Each stylesheet will change the background colour. There is also a random button, which will randomly select a stylesheet.