Jump to content

MediaWiki:Common.js

From Step 4
Revision as of 11:25, 16 July 2026 by AdamSinger (talk | contribs) (Use the device viewport instead of the fixed desktop width on mobile)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.
/* Step 4 mobile viewport correction for Vector 2022.
 * The server currently emits width=1120; replace it with the device width.
 * No maximum-scale restriction is used, so pinch-to-zoom remains available.
 */
(function () {
    'use strict';

    var viewport = document.querySelector('meta[name="viewport"]');
    var content = 'width=device-width, initial-scale=1, viewport-fit=cover';

    if (viewport) {
        viewport.setAttribute('content', content);
    } else {
        viewport = document.createElement('meta');
        viewport.setAttribute('name', 'viewport');
        viewport.setAttribute('content', content);
        document.head.appendChild(viewport);
    }
}());