Difference between revisions of "MediaWiki:Common.js"
Jump to navigation
Jump to search
| Line 1: | Line 1: | ||
| − | mw.loader.load("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11. | + | mw.loader.load( |
| − | mw.loader.load("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11. | + | "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js" |
| + | ); | ||
| + | mw.loader.load( | ||
| + | "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css", | ||
| + | "text/css" | ||
| + | ); | ||
| − | + | mw.loader.using([], function () { | |
| − | hljs.configure({ | + | // Wait until highlight.js is actually available |
| − | + | function initHighlight() { | |
| − | + | if (typeof hljs !== "undefined") { | |
| − | + | hljs.configure({ | |
| + | cssSelector: 'pre[class*="language-"]' | ||
| + | }); | ||
| + | hljs.highlightAll(); | ||
| + | } else { | ||
| + | // try again shortly | ||
| + | setTimeout(initHighlight, 50); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | initHighlight(); | ||
}); | }); | ||
Latest revision as of 22:53, 25 March 2026
mw.loader.load(
"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"
);
mw.loader.load(
"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css",
"text/css"
);
mw.loader.using([], function () {
// Wait until highlight.js is actually available
function initHighlight() {
if (typeof hljs !== "undefined") {
hljs.configure({
cssSelector: 'pre[class*="language-"]'
});
hljs.highlightAll();
} else {
// try again shortly
setTimeout(initHighlight, 50);
}
}
initHighlight();
});