Ask once with Notification.requestPermission(); if "granted", fire new Notification("Title", { body, icon }). For background/push notifications you combine this with a service worker and the Push API. Request permission in response to a user action, not on page load, or users (and browsers) will reject it.