MediaWiki:Common.js
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.
/* Any JavaScript here will be loaded for all users on every page load. */
mw.loader.using('mediawiki.util', function() {
$(document).ready(function() {
// 1. Inject the Snipcart Stylesheet into the Head
var snipcartStyle = document.createElement('link');
snipcartStyle.rel = 'stylesheet';
snipcartStyle.href = 'https://cdn.snipcart.com/themes/v3.0.31/default/snipcart.css';
document.head.appendChild(snipcartStyle);
// 2. Inject the Snipcart JavaScript Engine into the Head
var snipcartScript = document.createElement('script');
snipcartScript.src = 'https://cdn.snipcart.com/themes/v3.0.31/default/snipcart.js';
snipcartScript.async = true;
document.head.appendChild(snipcartScript);
// 3. Create the REQUIRED hidden container hidden in the Body for the API Key
if (!document.getElementById('snipcart')) {
var snipcartDiv = document.createElement('div');
snipcartDiv.id = 'snipcart';
snipcartDiv.setAttribute('data-api-key', 'NDQyNjc2NWQtYmQ5OS00MzZhLTkzMWEtMDBmOGQxYmNhZGJmNjM5MTY0NDgxODQ2NzAzNTgy');
snipcartDiv.hidden = true;
document.body.appendChild(snipcartDiv);
}
});
});