Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

Web Sharing is Web Caring

Phil Nash
September 10, 2019

Web Sharing is Web Caring

Third party JavaScript, tracking scripts, iframes! What are you doing with all those share buttons on your site?

The Web Share API is here and you should know about it! It's not just a new API though, it brings benefits to your users you may not have thought of.

What if you want to have things shared to your site though? Then you need to know how to become a Web Share Target. We'll check that out too.

Let's investigate how the web platform is solving problems you didn't know you had and making sharing a more caring part of the web.

Links:

The Web Share API: https://philna.sh/blog/2017/03/14/the-web-share-api/
Register as a Web Share Target: https://developers.google.com/web/updates/2018/12/web-share-target
Use the Web Share API easily with web components: https://philna.sh/blog/2018/04/25/web-share-api-with-web-components/
<web-share-wrapper>: https://github.com/philnash/web-share-wrapper

Phil Nash

September 10, 2019
Tweet

More Decks by Phil Nash

Other Decks in Programming

Transcript

  1. Page impact: Facebook and Twitter 12 extra requests 5 new

    origins No significant increase in perf metrics @philnash
  2. The Web Share API navigator.share({ title: pageTitle, url: url, text:

    shareText }) .then(() => console.log("Share success!")) .catch(() => console.log("Share failure!")); 01. 02. 03. 04. 05. @philnash
  3. The Web Share Target API Requires a service worker and

    web app manifest Needs to be an installable PWA @philnash
  4. The Web Share Target API "share_target": { "action": "/share-target/", "params":

    { "title": "title", "text": "text", "url": "url" } } 01. 02. 03. 04. 05. 06. 07. 08. @philnash
  5. The Web Share Target API window.addEventListener('DOMContentLoaded', () => { const

    parsedUrl = new URL(window.location); console.log('Title shared: ' + parsedUrl.searchParams.get('title')); console.log('Text shared: ' + parsedUrl.searchParams.get('text')); console.log('URL shared: ' + parsedUrl.searchParams.get('url')); }); 01. 02. 03. 04. 05. 06. @philnash
  6. Web Share API: Links The Web Share API: https://philna.sh/blog/2017/03/14/the-web-share-api/ Registering

    as a web share target: https://developers.google.com/web/updates/2018/12/web-share-target The Web Share API with web components: https://philna.sh/blog/2018/04/25/web-share-api-with-web-components/ @philnash