MediaWiki:Common.js
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)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
$(document).ready(function () { // Select all images in the content area $('#mw-content-text img').each(function () { var imgSrc = this.getAttribute('src'); // Only proceed if the src is valid and doesn't already have a preload if (imgSrc && !document.head.querySelector('link[rel="preload"][href="' + imgSrc + '"]')) { var link = document.createElement('link'); link.rel = 'preload'; link.as = 'image'; link.href = imgSrc; document.head.appendChild(link); } }); $('#mw-content-text img').each(function () { if (!$(this).attr('loading')) { $(this).attr('loading', 'lazy'); } }); });