<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div class="node-content"><p>I'm a bit confused about the usage of the Drupal.jsEnabled variable in javascript.</p><p>It is my understanding that Drupal sets this internally, and if 
Drupal.jsEnabled is true then Drupal calls all the functions under the 
Drupal.behaviors object - sorta like how non-Drupal sites use an 
after-the-DOM is loaded wrapper to call their javascript logic.</p><p>What I'm confused about is why do I find module developer 
tutorials (various web sites) where the Drupal / javascript examples are like this:</p><div class="codeblock"><code>// --------- this is the start of the file<br>if (Drupal.jsEnabled) {<br>&nbsp;&nbsp; $(document).ready(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; entire content of the javascript logic, all functions, vars and so in inside here<br>&nbsp;&nbsp; );<br>}<br>// ---------- this is the end of the file</code></div><p>Are such examples simply wrong? </p><p>I've been doing this, under the belief that my logic will only be 
called if javascript is available and only after the DOM is loaded:</p><div class="codeblock"><code>// --------- start of file<br>Drupal.behaviors.myModulesNamespace = function( context ) {<br>&nbsp;&nbsp;&nbsp; entire content of the javascript logic, all functions, vars and so in inside here<br>}<br>// ---------- end of file</code></div><p>Should I also be wrapping my "entire content of javascript logic" inside an "if (Drupal.jsEnabled)" conditional?</p></div><div><span class="Apple-style-span" style="font-family: Helvetica; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div>Sincerely,</div><div>-Blake</div><div><font class="Apple-style-span" face="Arial"><span class="Apple-style-span" style="font-size: medium;"><font class="Apple-style-span" face="Helvetica" size="3"><span class="Apple-style-span" style="font-size: 12px;"><br></span></font></span></font></div></span></span></div></span></div></body></html>