Custom JavaScript in 'MediaWiki:Common.js' is not working
javascript, mediawiki, wiki
Solution
Do not include `<script>` and `</script>` on the *.js page - it will be included as a separate JS file, not inline in the HTML page.
Note that you don't need `$wgAllowUserJs` for javascript pages in the `MediaWiki` namespace, only for ones in the `User` namespace. (There is a separate setting called `$wgUseSiteJs` for enabling scripts in the `MediaWiki` namespace, but it is on by default).
Problem
I fresh installed MediaWiki on my own server (latest version) I tried adding some JavaScript code to `MediaWiki:Common.js` In `localsettings.php`, `$wgAllowUserJs` is set to true I also tried adding the JavaScript to `User:Admin/vector.js` and `User:Admin/common.js` I cleared cache/cookies, used different browsers, JavaScript enabled, tried different computers The JavaScript code does not work at all. I viewed source and it's not there. ``` <!-- BEGIN Tynt Script --> <script type="text/javascript"> if(document.location.protocol=='http:'){ var Tynt=Tynt||[];Tynt.push('cAe5WESDOr4BZUacwqm_6r');Tynt.i={"ap":"Read more:"}; (function(){var s=document.createElement('script');s.async="async";s.type="text/javascript";s.src='http://tcr.tynt.com/ti.js';var h=document.getElementsByTagName('script')[0];h.parentNode.insertBefore(s,h);})(); } </script> <!-- END Tynt Script --> ```