bagelboy bagelboy - 1 month ago 10x
Javascript Question

HTML5 sessionStorage or for Chrome Extension?

I have a Chrome Extension that is only a content script. I want to persist some data that is calculated in the content script so I can easily access it while browsing without having to recalculate it on each page. I only need the data to be stored for the session.

I was looking at the API but it seems data will persist there past the session. I have previous experience using HTML5 sessionStorage, but I feel like I should be leveraging Google's API here.

Any input is appreciated, thanks!


Inside a content script, using sessionStorage will access and modify the sessionStorage of that site, not of your extension.

You must use if you want it to be available to content scripts on other sites and to avoid breaking the sites.

There is no automatic clearing of data, but you can create an event page that clears it on startup.


"background": { "scripts": [ "background.js" ], "persistent": false }


chrome.runtime.onStartup.addListener(function() {


Event Pages