Answers.Body: <p>Just remove these two logging routes from your plugin's init() method in your PluginHandlePlugin.php file:</p>
  
  <pre><code>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: 2014-06-26T01:23:51.370Z
Answers.Text: Worked perfectly. Wouldn't you always want these removed when using methods like `returnJson`, or anything that explicitly returns non-html?
Answers.UserDisplayName: Tim Kelty
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-26T06:59:45.223Z
Answers.Text: Entirely possible, I suppose.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-06-25T21:00:49.797Z
Answers.LastActivityDate: 2014-06-25T21:06:23.190Z
Answers.LastEditDate: 2014-06-25T21:06:23.190Z
Answers.UserDisplayName: Brad Bell
Body: <p>I have a plugin returning json from a controller action using <code>$this-&gt;returnJson(...)</code>.</p>
  
  <p>Works great in production, but when <code>devMode = true</code>, the json is invalidated because Craft is still dumping the console debugging script at the end of the content.</p>
  
  <p>What's the best way to avoid this?</p>
  
Tags: <plugin-development><json>
Title: Console script tags garbling up non-html output (e.g. json) when in devMode
ThreadText: # Console script tags garbling up non-html output (e.g. json) when in devMode
  
  (Asked by: username_0 on 2014-06-25)
  
  I have a plugin returning json from a controller action using `$this->returnJson(...)`.
  
  Works great in production, but when `devMode = true`, the json is invalidated because Craft is still dumping the console debugging script at the end of the content.
  
  What's the best way to avoid this?
  
  **Tags:** plugin-development, json
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-06-25. Score: 8 | Accepted answer
  
  Just remove these two logging routes from your plugin's init() method in your PluginHandlePlugin.php file:
  
  ```
  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**: Worked perfectly. Wouldn't you always want these removed when using methods like `returnJson`, or anything that explicitly returns non-html?  
  > **username_1**: Entirely possible, I suppose.  
  
  ---
  
  