Before the check with indexOf
use toLowercase
on both values, making the comparison case insensitive.
//Notice both n.nodeValue and word are sent to lowercase.
for (var i;
(i = n.nodeValue.toLowerCase().indexOf(word.toLowerCase(), i)) > -1;
n = after) {
var after = n.splitText(i + word.length);
var highlighted = n.splitText(i);
var span = document.createElement('span');
span.className = "spanClass";
span.style.backgroundColor = "red";
span.appendChild(highlighted);
after.parentNode.insertBefore(span, after);
}
JS FIDDLE: http://jsfiddle.net/LcRDz/2/