Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/**** Automatically-updating word count on edit pages ****/

// Counts words in a field
function countWords(field) { 
	return field && field.value ? field.value.split(/\s+/).length : 0;
}

// Creates <div id='word-count'>
function doWordCount() {
	if (document.title.slice(0,7) == "Editing") {
		var x = document.getElementById('editpage-copywarn');
		var y = document.getElementById('editform');
		if (x && y && y.wpTextbox1) {
			var z = document.createElement('div');
			z.id = 'word-count';
			x.appendChild(z);
			refreshCount();
		} else {
			alert('Missing element needed for word count');
		}
	}
}

// Auto-update content every ten seconds
function refreshCount() {
	var wc = '<small>Word count: ' + countWords(document.getElementById('editform').wpTextbox1) + '</small>';
	document.getElementById('word-count').innerHTML = wc;
	setTimeout(refreshCount, 10000);
}

$(doWordCount);