MediaWiki:Common.js

From HighSpell Wiki
Revision as of 20:13, 26 June 2025 by Ryan (talk | contribs)
Jump to navigation Jump to search

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);
        }
    });
});