Last active
November 13, 2023 18:24
-
-
Save achou11/7d9a9b4d67bda9ce472ed1d35dbee0ab to your computer and use it in GitHub Desktop.
Add a <meta> html tag to make sites more usable on mobile devices: https://developer.mozilla.org/en-US/docs/Web/HTML/Viewport_meta_tag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Call this function | |
| function addViewportMeta() { | |
| const head = document.head | |
| if (!head.querySelector('meta[name=viewport]')) { | |
| const meta = document.createElement('meta') | |
| meta.setAttribute("name", "viewport") | |
| meta.setAttribute("content", "width=device-width, initial-scale=1") | |
| head.appendChild(meta) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment