MediaWiki:Gadget-catchcalc-boot.js: Difference between revisions

From Pixelrus
Jump to navigation Jump to search
(Create MediaWiki:Gadget-catchcalc-boot.js)
 
m (Update MediaWiki:Gadget-catchcalc-boot.js)
 
Line 18: Line 18:
else { document.addEventListener( 'DOMContentLoaded', go ); }
else { document.addEventListener( 'DOMContentLoaded', go ); }
}() );
}() );
[[Category:Auto-generated]]

Latest revision as of 08:38, 15 June 2026

/*
 * Catch-calculator bootstrap (loads on every page, tiny).
 * This Gadgets version can't scope a gadget to a page/category, so instead we
 * ship this minimal loader sitewide and pull the heavy data + UI module
 * (ext.gadget.catchcalc-app, ~80 KB) only on pages that actually contain the
 * <div id="catch-calculator"> mount point.
 */
( function () {
	'use strict';
	function go() {
		if ( !document.getElementById( 'catch-calculator' ) ) { return; }
		mw.loader.using( [ 'ext.gadget.catchcalc-app' ] ).catch( function () {
			var n = document.getElementById( 'catch-calculator' );
			if ( n ) { n.textContent = 'Catch calculator failed to load.'; }
		} );
	}
	if ( document.readyState !== 'loading' ) { go(); }
	else { document.addEventListener( 'DOMContentLoaded', go ); }
}() );