nojs
Categories
Component ID
Component name
Component type
Maintenance status
Development status
Component security advisory coverage
Downloads
Component created
Component changed
Component body
Drupal normally adds the class "js" to the <html> element when javascript is enabled, allowing for the easy addition of .js to the beginning of any CSS selector if you want to theme something differently when javascript is enabled.
This out-of-the-box Drupal feature is great, but sometimes it's not good enough. As Paul Irish notes:
I prefer to write unique css for the no-javascript user. I don't want to be writing .js in front of every selector for my basic accordion/carousel/etc widgets. It's terribly tedious. I really just want a .no-js hook.
This module adds a "no-js" or "js" class, as appropriate, to the <body> element (not the <html> element).
Differences from Paul Irish's approach
Why don't we add it to the <html> element as Paul Irish does? Doing so would require overriding html.tpl.php, which is normally done by many themes. This module is designed to be extremely lightweight and theme-agnostic -- you should be able to use it with any theme! If we added "js" or "no-js" to the <html> element, we couldn't be so lightweight or cross-compatible with any theme. Instead, we apply the class to the <body> element.
Installation
Simply download and enable the module!
Sponsorship
Module development sponsored by GroupTracks. If you are interested in having this module customized, you can reach us at drupal@grouptracks.com.
