Skip to content

A simple way to dynamically switch the css and js of a site

License

Notifications You must be signed in to change notification settings

shelleyphant/css-switcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

css-switcher

A simple way to dynamically switch the css and js of a site

Using The Switcher

  • 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.

Additional Notes

  • The switcher will remember the last loaded stylesheet on page refresh
  • New visitors will be shown a random stylesheet

Working Example

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.

About

A simple way to dynamically switch the css and js of a site

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published