Title: Wordfence Bot JS causing validation errors
Last modified: July 31, 2018

---

# Wordfence Bot JS causing validation errors

 *  Resolved [cwdg](https://wordpress.org/support/users/cwdg/)
 * (@cwdg)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/wordfence-bot-js-causing-validation-errors/)
 * WordFence adds the javascript below when bots check the site. The issue is that
   this script now causes errors/warnings on all the code validation sites when 
   checking HTML5. The issue is that `type="text/javascript` is no longer needed
   and is considered an invalid attribute.
 * Is there a filter or method in which I can remove the type attribute from the
   script tag?
 *     ```
       <script type="text/javascript">↩
       (function(url){↩
       	if(/(?:Chrome\/26\.0\.1410\.63 Safari\/537\.31|WordfenceTestMonBot)/.test(navigator.userAgent)){ return; }↩
       	var addEvent = function(evt, handler) {↩
       		if (window.addEventListener) {↩
       			document.addEventListener(evt, handler, false);↩
       		} else if (window.attachEvent) {↩
       			document.attachEvent('on' + evt, handler);↩
       		}↩
       	};↩
       	var removeEvent = function(evt, handler) {↩
       		if (window.removeEventListener) {↩
       			document.removeEventListener(evt, handler, false);↩
       		} else if (window.detachEvent) {↩
       			document.detachEvent('on' + evt, handler);↩
       		}↩
       	};↩
       	var evts = 'contextmenu dblclick drag dragend dragenter dragleave dragover dragstart drop keydown keypress keyup mousedown mousemove mouseout mouseover mouseup mousewheel scroll'.split(' ');↩
       	var logHuman = function() {↩
       		if (window.wfLogHumanRan) { return; }↩
       		window.wfLogHumanRan = true;↩
       		var wfscr = document.createElement('script');↩
       		wfscr.type = 'text/javascript';↩
       		wfscr.async = true;↩
       		wfscr.src = url + '&r=' + Math.random();↩
       		(document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(wfscr);↩
       		for (var i = 0; i < evts.length; i++) {↩
       			removeEvent(evts[i], logHuman);↩
       		}↩
       	};↩
       	for (var i = 0; i < evts.length; i++) {↩
       		addEvent(evts[i], logHuman);↩
       	}↩
       })('//www.cwdgservices.com/?wordfence_lh=1&hid=D0BE414EEAD6F006FED4068FEC5077F8');↩
       </script>
       ```
   
    -  This topic was modified 7 years, 10 months ago by [cwdg](https://wordpress.org/support/users/cwdg/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Support [wfphil](https://wordpress.org/support/users/wfphil/)
 * (@wfphil)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/wordfence-bot-js-causing-validation-errors/#post-10551352)
 * Hi,
 * You will notice that WordPress itself also adds the type attribute to inline 
   JavaScript and CSS.
 * The script we load for detecting human visitors is created with document.createElement(‘
   script’) so how that ends up being constructed would depend on the browser.
 * It has been discussed here for your interest:
 * [https://core.trac.wordpress.org/ticket/42804](https://core.trac.wordpress.org/ticket/42804)
 *  Plugin Support [wfphil](https://wordpress.org/support/users/wfphil/)
 * (@wfphil)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/wordfence-bot-js-causing-validation-errors/#post-10551800)
 * Hi,
 * I have opened a bug case that if WordPress implements HTML 5 compliant inline
   JavaScript tags then we may consider doing the same.
 * Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Wordfence Bot JS causing validation errors’ is closed to new replies.

 * ![](https://ps.w.org/wordfence/assets/icon.svg?rev=2070865)
 * [Wordfence Security - Firewall, Malware Scan, and Login Security](https://wordpress.org/plugins/wordfence/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordfence/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordfence/)
 * [Active Topics](https://wordpress.org/support/plugin/wordfence/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordfence/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordfence/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [wfphil](https://wordpress.org/support/users/wfphil/)
 * Last activity: [7 years, 10 months ago](https://wordpress.org/support/topic/wordfence-bot-js-causing-validation-errors/#post-10551800)
 * Status: resolved