In reply to Rick Gregory.

Rick,

Better to put service workers in a plugin as many/most assets in Wordpress exist outside of the theme do plugins (being for generic functionality) are a better fit.

Otherwise I agree