Reputation:
I just learned a lot about how to avoid inclusion of "jQuery-min.js". The reason I thought I needed jQuery was to use $('someTag'). That was the only jQuery call I had in my document.
So I buckled down and learned a little about NodeLists
for the purpose of using document.getElementsByTagName
. See Specify an array without jQuery and without NodeLists [SOLVED .. I think?]
Now, I've come across Modernizer in my effort to include certain styles for Javascript and other styles for non-Javascript.
Obviously its size is microscopic compared to jQuery-min.js ... but it is another file I need to include. Besides, the presence of Modernizer eliminates a bunch of older Browsers that might still be used. Heaven knows "non-js" and "js" classes are very appealing ... but another file??
So ... without Modernizer, how can I include certain styles for Javascript and other styles for non-Javascript?? display:none
and display:block
are neat, but I need to dynamically switch back and forth depending on the presence of Javascript.
Contribution of ideas would be awesome!
Upvotes: 0
Views: 38
Reputation: 887509
You can write a single line of Javascript code to add a CSS class to your <body>
element:
document.body.classList.add('js');
Upvotes: 2