Maxim Salnikov

@webmaxru

Background-enabled

Web Apps

I want to have the possibility run some webapp code in the background

Today and on all platforms

Maxim Salnikov

  • Technical speaker

  • Web / Mobile  / PWA meetups organizer

  • ngVikings and Mobile Era conferences organizer

  • Building web since late 90s

Developer Engagement Lead at Microsoft Norway

Running code in the background

  • Extra value to the user experience

  • Privacy / security / performance considerations

  • Developer ergonomics

  • Based on Web standards

  • Progressive enhancement

Triggered by

Server command

Time event

Other event?

Push?

Geofence?

Battery status?

Network status?

Generic schedule?

Periodic events

Periodic background sync

const registration = await navigator.serviceWorker.ready;
if ('periodicSync' in registration) {
  try {
    await registration.periodicSync.register('content-sync', {
      // An interval of one day.
      minInterval: 24 * 60 * 60 * 1000,
    });
  } catch (error) {
    // Periodic background sync cannot be used.
  }
}
self.addEventListener('periodicsync', (event) => {
  if (event.tag === 'content-sync') {
    // Think before you sync!
    event.waitUntil(syncContent());
  }
});
  • 2000+ developers

  • Major browsers/frameworks/libs reps

Thank you!

Maxim Salnikov

@webmaxru

Made with Slides.com