Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

chrome.runtime.getURL vs. chrome.extension.getURL

What are the differences between chrome.runtime.getURL and chrome.extension.getURL?

The documentation implies that chrome.runtime.getURL works in both apps and extensions, and this 2012 announcement indicates that some APIs (though not getURL) have moved from chrome.extension to chrome.runtime.

What's the point of chrome.extension.getURL then, and why isn't it deprecated in favor of chrome.runtime.getURL?

like image 336
Dan Dascalescu Avatar asked Sep 02 '15 04:09

Dan Dascalescu


People also ask

What is window chrome runtime?

Description. Use the chrome. runtime API to retrieve the background page, return details about the manifest, and listen for and respond to events in the app or extension lifecycle. You can also use this API to convert the relative path of URLs to fully-qualified URLs.

Is a Chrome extension an API?

The chrome. extension API has utilities that can be used by any extension page. It includes support for exchanging messages between an extension and its content scripts or between extensions, as described in detail in Message Passing.

What is the function of Chrome extension?

A chrome extension is a way of adding functionality to the chrome browser. You can add interface elements, open and close tabs, interact with the address bar, as well as modify the contents of any page the browser is currently on.


2 Answers

The chrome.extension.getURL is now deprecated, you should use chrome.runtime.getURL.

From the chrome.extension.getURL's docs:

Deprecated since Chrome 58. Please use runtime.getURL.

like image 196
Or Duan Avatar answered Sep 16 '22 21:09

Or Duan


There isn't any, really.

There are some similar functions there with differences, like .getBackgroundPage, but in this case there's no effective difference.

And as you said yourself, it's not deprecated either. Why? Maybe just overlooked. extension API is older than runtime.

like image 45
Xan Avatar answered Sep 16 '22 21:09

Xan