← All examples

JavaScript Reading & focus

Bionic reading — bold word starts

Bolds the first letters of every word in the article, guiding the eye and speeding up reading.

Code to copy

(function () {
  var article = document.querySelector('article, .post, .entry-content, main');
  if (!article) return;
  var walker = document.createTreeWalker(article, NodeFilter.SHOW_TEXT);
  var nodes = [];
  while (walker.nextNode()) nodes.push(walker.currentNode);
  nodes.forEach(function (node) {
    if (!node.nodeValue || !node.nodeValue.trim()) return;
    if (node.parentNode && /SCRIPT|STYLE|CODE|PRE/.test(node.parentNode.nodeName)) return;
    var frag = document.createDocumentFragment();
    node.nodeValue.split(/(\s+)/).forEach(function (part) {
      if (!part.trim()) { frag.appendChild(document.createTextNode(part)); return; }
      var cut = Math.max(1, Math.ceil(part.length * 0.4));
      var b = document.createElement('b');
      b.textContent = part.slice(0, cut);
      frag.appendChild(b);
      frag.appendChild(document.createTextNode(part.slice(cut)));
    });
    node.parentNode.replaceChild(frag, node);
  });
})();

How to use this example

  1. Copy the code with the button above.
  2. Install JustZix (2 minutes) and open the extension on the target page.
  3. Add a new rule matching that page.
  4. Paste the code into the rule's JavaScript panel and save — it runs on every page visit.

Rate this example

No ratings yet — be the first.

Does this example work?

Snippets are useless without somewhere to paste them.

JustZix takes 2 minutes to install and runs your code on every matching page. No account, no payment.

Download free See use cases