docs.rodeo

MDN Web Docs mirror

icons

{{QuickLinksWithSubpages("/en-US/docs/Web/Progressive_web_apps/Manifest/Reference")}} 

The icons manifest member is used to specify one or more image files that define the icons to represent your web application.

Syntax

/* Single icon with the minimum required property */
"icons": [
  {
    "src": "icon/basic-icon.png"
  }
]

/* Single icon with multiple purposes */
"icons": [
  {
    "src": "icon/basic-icon.png",
    "purpose": "monochrome maskable"
  }
]

/* Two icons with various properties */
"icons": [
  {
    "src": "icon/low-res.png",
    "sizes": "48x48"
  },
  {
    "src": "maskable_icon.png",
    "sizes": "48x48",
    "type": "image/png"
  }
]

Values

Description

Icons uniquely identify your web app in different contexts, such as in an operating system’s task switcher, system settings, home screen, app listings, and other places when application icons are displayed.

The context in which an icon can be used is determined by the browser and the operating system, based on the specified sizes and formats.

Security considerations

The browser’s ability to fetch an icon image is governed by the Content Security Policy ({{Glossary("CSP")}} ) of the manifest’s owner document, specifically by the img-src directive. This security aspect is related to the src property.

For example, if the img-src directive in a CSP header specifies icons.example.com, icons from only that domain would be fetchable. In a manifest with two icons, one from icons.example.com/low-res and another from other.com/hi-res, only the former would be fetched successfully because of CSP restrictions.

Performance considerations

Specifying the type property can significantly improve performance because it allows browsers to ignore images with unsupported formats more easily. If you don’t specify the type property, browsers may need to infer the image format using more resource-intensive methods, such as MIME sniffing the file for a signature.

At a minimum, if you omit the type property, use appropriate and unambiguous file extensions for your icon images.

Examples

Declaring multiple icons

This example shows how to declare multiple icons for different scenarios and devices. If an icon for a specific situation is not supported or not available, browsers will fall back to other available formats and sizes.

{
  "icons": [
    {
      "src": "icon/low-res.webp",
      "sizes": "48x48",
      "type": "image/webp"
    },
    {
      "src": "icon/low-res",
      "sizes": "48x48"
    },
    {
      "src": "icon/hd_hi.ico",
      "sizes": "72x72 96x96 128x128 256x256"
    },
    {
      "src": "icon/hd_hi.svg",
      "sizes": "any"
    }
  ]
}

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

See also

In this article

View on MDN