usersnap and the javascript magic behind the scenes - viennajs

18
2014-05-28 Sektor5 Usersnap for developers and the Javascript magic we do behind the scenes

Upload: usersnap

Post on 15-Jan-2015

137 views

Category:

Software


1 download

DESCRIPTION

The Usersnap guys (@fdorfbauer and @josef_trauner) present at ViennaJS what they are doing behind the scenes with their widget and which problems can occur when you develop a widget which will be included in 3rd party sites! The example code is located in our github repo: https://github.com/usersnap/public/tree/master/misc/viennajs

TRANSCRIPT

Page 1: Usersnap and the javascript magic behind the scenes - ViennaJS

2014-05-28 Sektor5

Usersnap for developers and the Javascriptmagic we do behind the scenes

Page 2: Usersnap and the javascript magic behind the scenes - ViennaJS

Who are we?

Page 3: Usersnap and the javascript magic behind the scenes - ViennaJS

What is Usersnap?

Page 4: Usersnap and the javascript magic behind the scenes - ViennaJS

The problem

Working on a web project can be hard

Page 5: Usersnap and the javascript magic behind the scenes - ViennaJS

The problem

Communication is not always frictionless, due to differences in the background.

Are you talking about the logo?

What‘s a Logo?

What is this rainbow-shaped thing on the top of your page?

Page 6: Usersnap and the javascript magic behind the scenes - ViennaJS

The solution

We unify communication between all parties involved in the process, including the end users.

Page 7: Usersnap and the javascript magic behind the scenes - ViennaJS

Demo + How we serve your screenshot.

Page 8: Usersnap and the javascript magic behind the scenes - ViennaJS

No

Inte

rweb

s?De

mo

Fallb

ack

Page 9: Usersnap and the javascript magic behind the scenes - ViennaJS

Usersnap Widget

The annotation process of Usersnap is done by a small JavaScript snippet!

It’s embedded in 3rd party websites.

Page 10: Usersnap and the javascript magic behind the scenes - ViennaJS

3rd Party Sites ;-)

Have you ever tried adding code in unkown 3rd party sites?• external libraries/scoping (jQuery, SVG,…)• overwrite CSS properties• Iframe sandboxing• transmitting data: Cross Origin Problem• overwrite JS defaults

Page 11: Usersnap and the javascript magic behind the scenes - ViennaJS

external Libraries

• It can stop your javascript code.• OR it can stop the site which has

embedded your code -> NO GO.• You could probabily overwrite a used

library. -> showcase 0• Use your own static codebase.• Do not rely on any external CDN

Page 12: Usersnap and the javascript magic behind the scenes - ViennaJS

Overwrite CSS properties

• You are not able to control every possible property!

• Never say: No one will use such properties!• We thought we could do that job ;-)

Page 13: Usersnap and the javascript magic behind the scenes - ViennaJS

Overwrite CSS properties

showcase 1

Page 14: Usersnap and the javascript magic behind the scenes - ViennaJS

Iframe Sandboxing

• Solution for the CSS problem.• No design restrictions anylonger.• Clean global scope.

showcase 2

Page 15: Usersnap and the javascript magic behind the scenes - ViennaJS

Transmitting Data

• JsonP– small get requests (permissions, key

verification).• HTTP-Post

– Transfer data to the server.– Cross Origin Problem.– Important to deliver error messages

showcase 3

Page 16: Usersnap and the javascript magic behind the scenes - ViennaJS

Transmitting Data

• Solution: iframe PostMessages– work with Cross Origin Policy

showcase 3B• Problem with PostMessage

– The website itself is using postMessages– again iframe Sandboxing

showcase 4

Page 17: Usersnap and the javascript magic behind the scenes - ViennaJS

Overwrite Browser defaults

• don‘t trust in browser functions• example: custom JSON parser.• such errors are very hard to reproduce.

showcase 5

Page 18: Usersnap and the javascript magic behind the scenes - ViennaJS

Summary

• Don‘t trust in third party code.• Use iframe sandboxing for secure

environment.• Good error checking! Your customer will

thank you!