126 points · by andRyanMiller · 8y ago · 66 comments
For example, I want Messenger to send me notifications if I have the tab open, but I don't want the service worker to maintain a persistent connection and send me notifications with the tab closed.
Unfortunately, I am not able to block service workers. My only option is to block notifications entirely, which doesn't even stop the service worker.
More broadly, I agree that it is strange you can opt into the Push API without a permission prompt. I wish it weren't the case, but I do think it would be confusing to users to request separate push and notification permissions - most consider them to be synonymous, even if they aren't.
The notifications dropdown should be:
- Always allow
- Allow when open
- Disallow
Question, I’d like to avoid doing large downloads or possibly cap the transfer rate to avoid any potential jank. Is there a best practice or is it possible to monitor the current browser interaction to determine how strategically best to pull data with a SW?
Depending on what a user chooses to cache, it’s JSON data (1-10MB) going to a mix of localstorage and indexedDB.
That should allow you to sum up download sizes.
It’s also configurable to only operate on faster connections/non mobile IP address etc.
The main reason I was asking is if you currently benchmark service worker updates with indexedDB for async/larger updates, they still cause a small amount of jank, (at least on larger requests) even though they may use a different process etc.
There’s a github repo with a benchmark, this link is older but if you clone the current version and update to the lastest packages, the results are still similar.
https://www.google.com/amp/s/nolanlawson.com/2015/09/29/indexeddb-websql-localstorage-what-blocks-the-dom/amp/Loading 1-10MB JSON might drain a significant portion of mobile data. It could take a long time, meaning it may need to re-start it a couple of times, due to, say, a flaky 3G connection.
I'm curious on the why - unless this is an announced feature, I don't think this should be an automatic process and should only be done on user demand explicitly.
".. by authoring special-purpose JavaScript which you register with the browser."
Why does this seem like something useful for malware and generally annoying me.
If I popped up a dialog box asking to harvest a kidney 30% of users would click yes.
I would we rather leave http to be a document model, and create something new and better to support"web-based" apps.
Kinda sucks that something with such promise is predominantly used as just another weapon for tracking.
about:config
dom.serviceWorkers.enabled;false
Why:They bite. The generic idea may even be reasonable (offline working web app), but every single time I encounter service workers they make things worse.
If you load a React frontend, it'll, by default, deploy a service worker. Good luck trying to load anything non-react from that resource/server.
I never asked for a web app to work in the background once I closed a site. Nobody should be trained to expect websites work in the background - that is not how they are. If there is no tab open, there should be no notification, no nothing. That is how the web works.
And SVGOMG is able to load faster thanks to service workers, too.
At FastMail, we’ll be getting round to adding service workers some time soon, and it’ll actually give us a quite fascinating performance boost: even without supporting full offlineness, simply caching the basic data you need can get you to the point where you need literally no requests before you can load the interface, showing meaningful data to the user, and then fetch updated data in the background. I’m confident we’ll be able to get startup time to under two seconds with service workers for code and data loading/caching, and hopeful that we’ll get it down to under a second.
Service workers can be badly implemented, but they also offer the possibility of some quite delightful improvements in websites and web apps.
Be careful what offline actually means when it comes to mail; eg. that 22GB as service worker cache sounds a bit nasty to me, especially because service workers don't tend to differentiate between desktop and mobile.
I think you mean that create-react-app is doing this by default, and that it might be a surprise and cause of problems for the developer. Which is also the reason why they're removing that by default from create-react-app v2.
> That is how the web works.
That's not really an argument, in that it also could've been used as an argument against the introduction of inline images, CSS, or anything added to the web after its first publication. It doesn't really matter how the web works today; what's relevant is how we want the web to work.
good luck trying to convince google of that. they are shaping the web just the way they want it. push notifications? nobody ever except the marketing apartment thought that was a good idea to add to anything. if we try making everything on the web like mobile apps we're gonna get garbage features like this and false expectations on what the web should be like.
EDIT: I also used Service-Workers in the same project to provide offline functionality :) It worked great, I was suprised how good it worked!
I'd wager you encounter more service workers than you think, but you don't notice them when they work correctly. They are designed to be invisible in the majority of cases, so of course you only notice them when something goes wrong.
What?
> That is how the web works.
The web 'experience' has stopped being about fetching static documents in a request/response fashion long ago. Consumers demand rich apps and interactivity, and it appears they're having it their way.
https://github.com/facebook/create-react-app/issues/2398
> Consumers demand rich apps and interactivity
They really don't. That's an assumption without data.
EDIT: see gov.uk. It works quite well without being fancy.
Equating 'create-react-app' package with React is silly. By that logic, I can wrap $library_of_your_choice in scaffolding and then blame it for the bloat I've chosen to add.
> EDIT: see gov.uk. It works quite well without being fancy.
We're at an impasse, since you countered my 'assumption without data' with your 'one-off anecdotal evidence'
no consumer ever demanded the web to be like an app. this is marketing baloney crap. stop treating humans browsing the web as targets for advertisement and consumerism.
For-profit companies typically build toward what they believe is in-demand and will be well-received by consumers. They perform market analysis to reinforce their intuition. Sometimes they get it right and their stock goes up.
There isn't some elaborate plot on the part of Google, nor are 'they' purposely making something 'no consumer ever demanded.' When they do this, the endeavor fails and we call it a flop.
Yes, wouldn't it be wonderful if we could do this in all major browsers today? sigh