runtime.onStartup

Fired when a profile that has this extension installed first starts up. This event is not fired when a private browsing (incognito) profile is started, even if this extension is operating in 'split' incognito mode.

Note: When using an event page or background service worker, the extension must add a listener to runtime.onStartup on the event page for the event page to be executed at least once per browser session.

Syntax

js
browser.runtime.onStartup.addListener(listener)
browser.runtime.onStartup.removeListener(listener)
browser.runtime.onStartup.hasListener(listener)

Event Functions

All events have three functions:

addListener(listener)

Adds a listener to the calling event.

removeListener(listener)

Stop listening to the calling event. The listener argument is the listener to remove.

hasListener(listener)

Checks whether a listener is registered for the calling event. Returns true if it is listening, false otherwise.

Parameters

The only parameter is listener, used for any of the above functions.

listener

The function called when this event occurs.

Examples

Open https://giphy.com/explore/cat when the browser starts up:

js
function handleStartup() {
  browser.tabs.create({
    url: "https://giphy.com/explore/cat",
  });
}

browser.runtime.onStartup.addListener(handleStartup);

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
onStartup
Chrome – Full support
Chrome 23 (Release date: 2012-11-06)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 52 (Release date: 2017-03-07)
footnote Full support
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 14 (Release date: 2020-09-16)
footnote Full support
Firefox for Android – Full support
Firefox for Android 52 (Release date: 2017-03-07)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15 (Release date: 2021-09-20)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

Note: This API is based on Chromium's chrome.runtime API. This documentation is derived from runtime.json in the Chromium code.