MediaWiki:Gadget-Preload Page Images.js

/* Preload next page image in Page namespace */

$(function {	var page = mw.config.get('wgPageName');	var next = page.replace(/(.*\/)(\d+)$/, function(match, p1, p2) { return p1 + (parseInt(p2) + 1); });	var query = {	   "action": "query",	    "format": "json",	    "prop": "imageforpage",	    "titles": next,	    "formatversion": "2"	};	var api = new mw.Api;	api.get(query).done(prefetchImages); });

function prefetchImages (data) { var images = data.query.pages[0].imagesforpage; var promises = []; promises.push($.get(images.thumbnail)); promises.push($.get(images.responsiveimages["1.5"])); promises.push($.get(images.responsiveimages["2"])); //	promises.push($.get(images.fullsize)); /* Fullsize doesn't seem to be used for anything and could be huge. */

Promise.all(promises).then(function {		$('#ca-proofreadPageNextLink a').css({ 'border-bottom': '3px solid lightgreen' });	}); }