Discard newly created tabs

211 views
Skip to first unread message

PIYUSH BANSAL

unread,
Jul 28, 2020, 11:34:05 AM7/28/20
to Chromium Extensions
Is there any way to create new tabs in discarded mode? In firefox, tabs.create api used option 'discard: true' to create new tabs in discarded mode.

But since chrome does not support anything of such type, is there any way to achieve it. I tried creating a tab and discarding right after. But clicking on that tab is not reloading the tab.

PhistucK

unread,
Jul 28, 2020, 11:43:46 AM7/28/20
to PIYUSH BANSAL, Chromium Extensions
I think (automatic?) tab discarding was dropped altogether as a Chrome feature some time ago... But I might have misunderstood.



PhistucK


On Tue, Jul 28, 2020 at 6:34 PM PIYUSH BANSAL <bansalp...@gmail.com> wrote:
Is there any way to create new tabs in discarded mode? In firefox, tabs.create api used option 'discard: true' to create new tabs in discarded mode.

But since chrome does not support anything of such type, is there any way to achieve it. I tried creating a tab and discarding right after. But clicking on that tab is not reloading the tab.

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/09dd2af0-5833-4233-a5eb-f4e2d5a08a9bo%40chromium.org.

PIYUSH BANSAL

unread,
Jul 29, 2020, 1:02:20 AM7/29/20
to Chromium Extensions
Not automatic tab discarding, but discarding them manually. I think tab discarding is still present as chrome provides tabs.discard api to discard them. But discarding them just after creation does not work.


On Tuesday, July 28, 2020 at 9:13:46 PM UTC+5:30, PhistucK wrote:
I think (automatic?) tab discarding was dropped altogether as a Chrome feature some time ago... But I might have misunderstood.



PhistucK


On Tue, Jul 28, 2020 at 6:34 PM PIYUSH BANSAL <bansalp...@gmail.com> wrote:
Is there any way to create new tabs in discarded mode? In firefox, tabs.create api used option 'discard: true' to create new tabs in discarded mode.

But since chrome does not support anything of such type, is there any way to achieve it. I tried creating a tab and discarding right after. But clicking on that tab is not reloading the tab.

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.

PhistucK

unread,
Jul 29, 2020, 2:01:30 AM7/29/20
to PIYUSH BANSAL, Chromium Extensions
Does discarding them after a few seconds work right now?

PhistucK


On Wed, Jul 29, 2020 at 8:02 AM PIYUSH BANSAL <bansalp...@gmail.com> wrote:
Not automatic tab discarding, but discarding them manually. I think tab discarding is still present as chrome provides tabs.discard api to discard them. But discarding them just after creation does not work.

On Tuesday, July 28, 2020 at 9:13:46 PM UTC+5:30, PhistucK wrote:
I think (automatic?) tab discarding was dropped altogether as a Chrome feature some time ago... But I might have misunderstood.



PhistucK


On Tue, Jul 28, 2020 at 6:34 PM PIYUSH BANSAL <bansalp...@gmail.com> wrote:
Is there any way to create new tabs in discarded mode? In firefox, tabs.create api used option 'discard: true' to create new tabs in discarded mode.

But since chrome does not support anything of such type, is there any way to achieve it. I tried creating a tab and discarding right after. But clicking on that tab is not reloading the tab.

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/4befab5c-2d2d-4285-bd1e-f46577f66fc8o%40chromium.org.

Adi Bhaskar

unread,
Jul 29, 2020, 10:32:31 AM7/29/20
to Chromium Extensions, PIYUSH BANSAL
Code wise, this should resolve your issue:

chrome.tabs.create({
    url: "https://c306.net/",
}, tab =>
    !chrome.runtime.lastError && chrome.tabs.update(tab.id, { discarded: true })
)

However, when I try it, I get an error saying unexpected property 'discarded'. So I guess Phistuck is correct, discarding has been removed. Just the API docs haven't been updated yet.

Cheers!

Adi

PhistucK

unread,
Jul 29, 2020, 11:37:39 AM7/29/20
to Adi Bhaskar, Chromium Extensions, PIYUSH BANSAL
You would be surprised (:)), but the documentation does not list discarded: true as supported in chrome.tabs.update.
Instead, there is the (weird) chrome.tabs.discard.

PhistucK


--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.

Adi Bhaskar

unread,
Jul 29, 2020, 12:38:42 PM7/29/20
to Chromium Extensions, PhistucK, Chromium Extensions, PIYUSH BANSAL, Adi Bhaskar
Thanks PhistucK! Learnt something new :)

Also learnt that discarding from callback of a created tab discards it right away, i.e. as a blank tab.

Based on this, my guess is to use `chrome.tabs.onUpdated` to check for tab to finish loading (status: complete), then discard it. You'd need to keep track of the tabId in your background script.
Reply all
Reply to author
Forward
0 new messages