-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Viewer: add sw for ATHS #1571
Viewer: add sw for ATHS #1571
Conversation
cc @XhmikosR |
Pardon my ignorance but what dones ATHS stand for? Apart from that the changes look good. I was in the verge when I added manifest.json if it should be in root or not, but agreed this is simpler. |
Ah. Short for "Add to Homescreen" |
You guys make acronyms out of everything :P |
@@ -43,3 +43,10 @@ Promise.all(loadPolyfillPromises).then(_ => { | |||
// eslint-disable-next-line no-new | |||
new LighthouseViewerReport(); | |||
}); | |||
|
|||
if ('serviceWorker' in navigator) { | |||
navigator.serviceWorker.register('/sw.js', {scope: './'}).catch(e => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't that scope implied? (iirc, the default scope matches the path of the SW resource?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been told to ALWAYS use scope. @jeffposnick says so!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm % nits
@@ -21,7 +21,7 @@ | |||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1"> | |||
<title>Lighthouse Report Viewer</title> | |||
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAADjklEQVR4AWI08P/HQEvAQrxSQKvlECfLFYXx75xCY2qmh89GbNvOMjb3v9jOOlxnFWxj206ebQ3b7q6q+z1rNagu8/zvPSZACAABpeUAA0miMgU7SA7JjCraFGwZwECOwvL75dWjsKg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ABJRU5ErkJggg=="> | |||
<link rel="manifest" href="images/manifest.json"> | |||
<link rel="manifest" href="manifest.json"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you throw the manifest link above the favicon reference?
IMO makes sense before, based on priority.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if ('serviceWorker' in navigator) { | ||
navigator.serviceWorker.register('/sw.js').catch(e => { | ||
// eslint-disable-next-line no-console | ||
console.error('Error during service worker registration:', e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, we probably want to register this at ${location.pathname}sw.js
so it is restricted to googlechrome.github.io/lighthouse/viewer/
and also works on localhost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
navigator.serviceWorker.register('sw.js')
for that matter.
PTAL for sanity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM sanity-wise
@@ -0,0 +1 @@ | |||
// Intentionally empty for now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs license :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
if ('serviceWorker' in navigator) { | ||
navigator.serviceWorker.register('sw.js').catch(e => { | ||
// eslint-disable-next-line no-console |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this file is only for running in the browser, want to just do /* eslint-disable no-console */
at the top of the file? Or is it better to keep it around to cut down on console
calls left over from development?
(the rule is a bit annoying for debugging in viewer and in the extension since both have the gulp lint
task as a required prerequisite for gulp build
, but it's not the end of the world)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just removed the .catch
for now. We don't care if this shell sw fails to register.
R: all
Follow up on #1554. Adds a shell sw so ATHS works.