MediaWiki:Common.js: Difference between revisions

From Crafters Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
   const css = document.createElement('link');
   const css = document.createElement('link');
   css.rel = 'stylesheet';
   css.rel = 'stylesheet';
   css.href = 'https://ehhthan.github.io/widgets/book-styles.css';
   css.href = 'https://ehhthan.github.io/book-display/widget.css';
   head.appendChild(css);
   head.appendChild(css);


   // JS: main gadget (depends on commons)
   // JS: main gadget (depends on commons)
   const gadget = document.createElement('script');
   const gadget = document.createElement('script');
   gadget.src = 'https://ehhthan.github.io/widgets/bookDisplayWidget.js';
   gadget.src = 'https://ehhthan.github.io/book-display/widget.js';
   gadget.defer = true;
   gadget.defer = true;
   head.appendChild(gadget);
   head.appendChild(gadget);
});
});

Revision as of 20:34, 1 August 2025

mw.loader.using('mediawiki.util', function () {
  const head = document.head;

  // CSS (optional)
  const css = document.createElement('link');
  css.rel = 'stylesheet';
  css.href = 'https://ehhthan.github.io/book-display/widget.css';
  head.appendChild(css);

  // JS: main gadget (depends on commons)
  const gadget = document.createElement('script');
  gadget.src = 'https://ehhthan.github.io/book-display/widget.js';
  gadget.defer = true;
  head.appendChild(gadget);
});