Check if user prefers dark mode using the prefers-color-scheme media query.
Code
Utilitieswindow.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;Parameters
Example parameter.
Browser·fetch() may be limited by CORS
More JavaScript Snippets
Clear LocalStorage
Clear all items from localStorage in the browser.
Copy to Clipboard
Copy text to the clipboard using the Clipboard API.
Delete Cookie
Delete a browser cookie by setting its expiration date to the past.
Detect Mobile Device
Check if user is on a mobile device by examining the user agent string.
Get Cookie
Get a cookie value by name from document.cookie.
Get LocalStorage
Retrieve a value from localStorage by key.