Answers.Body: <p>You can't disable the debugging output using Twig/templates.</p>
  
  <p>However, Craft will only render the debug data if your document' Content-type header is either "text/html" or "application/xhtml+xml" (<a href="https://craftcms.stackexchange.com/a/2294/1098">source</a>).</p>
  
  <p>This means that if you're outputting JSON, you can set the template's Content-type to "application/json" (using Craft's <a href="http://buildwithcraft.com/docs/templating/tags#header" rel="nofollow noreferrer">header tag</a>), preventing Craft from dumping the debug data to the response:</p>
  
  <pre><code>{% header "Content-Type: application/json" %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-06T12:27:33.140Z
Answers.LastActivityDate: 2015-03-06T12:27:33.140Z
Answers.LastEditDate: 2017-04-13T12:51:00.303Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Answers.Body: <p>You can create a simple plugin with an <code>init()</code> method like so:</p>
  
  <pre><code>public function init()
  {
      craft()-&gt;log-&gt;removeRoute('WebLogRoute');
      craft()-&gt;log-&gt;removeRoute('ProfileLogRoute');
  }
  </code></pre>
  
  <p>That will prevent the extra logging and profiling information to be output in the browser's console when devMode is enabled.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-06T12:15:55.770Z
Answers.Text: Thanks Brad - good to know. Setting the Content-Type was enough in the end, at least for this particular scenario.
Answers.UserDisplayName: Russ Back
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-21T01:29:15.603Z
Answers.Text: I putt this on github if people are feeling lazy: https://github.com/crswll/silence
Answers.UserDisplayName: Bill Criswell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-05T16:31:41.540Z
Answers.LastActivityDate: 2015-03-05T16:31:41.540Z
Answers.UserDisplayName: Brad Bell
Body: <p>For example the template just outputs JSON, which breaks when Craft's devMode logging is added.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-05T16:16:40.367Z
Comments.Text: I'm not aware of any way to disable the debugging output from the template, but if you use the header tag to explicitly set the document's content type to JSON, Craft wont output the debug data:
  
  ```{% header "Content-Type: application/json" %}```
Comments.UserDisplayName: Mats Mikkel Rummelhoff
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-06T12:15:31.853Z
Comments.Text: Thanks Mats - worked fine. Do you want to create an answer so I can mark it as accepted?
Comments.UserDisplayName: Russ Back
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-03-06T12:28:21.470Z
Comments.Text: That's great – I added an answer, thanks for following up.
Comments.UserDisplayName: Mats Mikkel Rummelhoff
Tags: <templating><javascript><devmode>
Title: Is it possible to disable dev output in a template when devMode is true?
ThreadText: # Is it possible to disable dev output in a template when devMode is true?
  
  (Asked by: username_0 on 2015-03-05)
  
  For example the template just outputs JSON, which breaks when Craft's devMode logging is added.
  
  **Tags:** templating, javascript, devmode
  
  > **Comments:**
  > **username_1**: I'm not aware of any way to disable the debugging output from the template, but if you use the header tag to explicitly set the document's content type to JSON, Craft wont output the debug data:  ```{% header "Content-Type: application/json" %}```  
  > **username_0**: Thanks username_1 - worked fine. Do you want to create an answer so I can mark it as accepted?  
  > **username_1**: That's great – I added an answer, thanks for following up.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-03-06. Score: 4 | Accepted answer
  
  You can't disable the debugging output using Twig/templates.
  
  However, Craft will only render the debug data if your document' Content-type header is either "text/html" or "application/xhtml+xml" ([source](https://craftcms.stackexchange.com/a/2294/1098)).
  
  This means that if you're outputting JSON, you can set the template's Content-type to "application/json" (using Craft's [header tag](http://buildwithcraft.com/docs/templating/tags#header)), preventing Craft from dumping the debug data to the response:
  
  ```
  {% header "Content-Type: application/json" %}
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2015-03-05. Score: 7
  
  You can create a simple plugin with an `init()` method like so:
  
  ```
  public function init()
  {
      craft()->log->removeRoute('WebLogRoute');
      craft()->log->removeRoute('ProfileLogRoute');
  }
  
  ```
  
  That will prevent the extra logging and profiling information to be output in the browser's console when devMode is enabled.
  
  > **Comments:**
  > **username_0**: Thanks username_2 - good to know. Setting the Content-Type was enough in the end, at least for this particular scenario.  
  > **username_3**: I putt this on github if people are feeling lazy: https://github.com/crswll/silence  
  
  ---
  
  