DEV Community

Cover image for Device Memory API
Raymond Wangsa Putra
Raymond Wangsa Putra

Posted on

Device Memory API

What is this?

This is one of Web APIs that can be used to get how much memory this device got

Compatibility?

Per this article is written, it only support Chrome, Edge, and Opera

How to use it?

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Device Memory API Example</title>
</head>
<body>
    <h1>Device Memory API Example</h1>
    <p id="memory-info"></p>

    <script>
        if ('deviceMemory' in navigator) {
            const memory = navigator.deviceMemory;
            document.getElementById('memory-info').textContent = `This device has approximately ${memory} GB of RAM.`;
        } else {
            document.getElementById('memory-info').textContent = 'Device Memory API is not supported on this browser.';
        }
    </script>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode

My observation?

One unique thing I observe it shows I only have 8GBs of RAM while running it on a 16GBs device

Top comments (0)

Image of AssemblyAI

Automatic Speech Recognition with AssemblyAI

Experience near-human accuracy, low-latency performance, and advanced Speech AI capabilities with AssemblyAI's Speech-to-Text API. Sign up today and get $50 in API credit. No credit card required.

Try the API

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay