Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mohamedkhallouq
GitHub Repository: mohamedkhallouq/content
Path: blob/main/files/en-us/mozilla/add-ons/webextensions/api/runtime/onstartup/index.md
6552 views
---
title: runtime.onStartup slug: Mozilla/Add-ons/WebExtensions/API/runtime/onStartup page-type: webextension-api-event tags: - API - Add-ons - Event - Extensions - Non-standard - Reference - WebExtensions - onStartup - runtime browser-compat: webextensions.api.runtime.onStartup
---

{{AddonSidebar()}}

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.

Syntax

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

    • : A function that will be called when this event occurs.

Browser compatibility

{{Compat}}

Examples

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

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

{{WebExtExamples}}

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