MediaWiki:Gadget-Select2.js

// Load the Select2 library function loadScript(url) { var script = document.createElement('script'); script.src = url; script.async = false; document.head.appendChild(script); }

function loadStylesheet(url) { var link = document.createElement('link'); link.href = url; link.rel = 'stylesheet'; document.head.appendChild(link); }

loadScript('https://cdnjs.cloudflare.com/ajax/libs/select2/4.1.0-rc.0/js/select2.min.js'); loadStylesheet('https://cdnjs.cloudflare.com/ajax/libs/select2/4.1.0-rc.0/css/select2.min.css');

// Initialize Select2 after the library is loaded function initializeSelect2 { if (typeof $.fn.select2 !== 'undefined') { $('.filter-select').select2; } else { setTimeout(initializeSelect2, 100); } }

$(document).ready(function {   initializeSelect2; });