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

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay