I’m building a Drupal theme up and want to know if there is a Drupalish way to add a css file only if the user has js turned off.
This would ideally go in the theme.info file to keep it neat!
Something like this would be ideal:
conditional-stylesheets[if no javascript][all][] = nojs.css
If this isn’t possible then I’m going to keep all the css that needs JS out of the css files, and add it dynamically using JS but this seems a bit messy…
Any ideas?
You don’t need conditional comments or noscript-tags for that. By default, Drupal adds a ‘js’ class to the html element and sets a cookie if javascript is enabled:
(That’s on line 296 in /misc/drupal.js.)
All css selectors that should only apply when js is enabled, can be prefixed with
.js. If you want, you can put those css rules in a separate file, but you don’t have to.