I have some code that is designed to count the amount of characters in the text of a website. Currently, it still counts <style> and <script> tags, even though I set it not to. Is there any way to fix this? My code is below.
new.js:
$(document).ready(function() {
var length = $("body").contents().filter(function(){
return (this.localName != "script" && this.localName != "style") ? true : false;
}).text().replace(/ +/g, "").length;