SlideShare une entreprise Scribd logo
1  sur  52
Télécharger pour lire hors ligne
Distributed JavaScript
                        Widgets w/ jQuery
                                   jQueryConf Boston 2010




Sunday, October 17, 2010
Who invited this guy?


                    • Ben Vinegar
                    • Front-end Engineer at Disqus
                    • Former team lead at FreshBooks
                    • Somewhere in there, Guestlist

Sunday, October 17, 2010
•      dis·cuss • dĭ-skŭs'

                    • Distributed commenting platform
                    • Served on over 300k sites
                    • ~200m unique visitors per month

Sunday, October 17, 2010
What’s a distributed
                            JavaScript widget?



Sunday, October 17, 2010
Sunday, October 17, 2010
Sunday, October 17, 2010
Vague definition

                    • Begins with a JavaScript snippet
                    • Lives on somebody else’s website
                    • Visible, interactive UI elements


Sunday, October 17, 2010
Let’s make one



Sunday, October 17, 2010
The pitch




Sunday, October 17, 2010
index.html




Sunday, October 17, 2010
widget.js




Sunday, October 17, 2010
widget.js cont’d




Sunday, October 17, 2010
Where’s jQuery?



Sunday, October 17, 2010
Some choices

                    • Distribute jQuery include with snippet

                    • Copy/paste into widget.js
                    • Dynamic script include from widget.js

Sunday, October 17, 2010
Dynamic include




Sunday, October 17, 2010
More problems



Sunday, October 17, 2010
jQuery conflicts

                    • What if it already exists? (Likely)
                    • Use $.noConflict
                    • Does more than let you use Dojo,
                           Mootools, Prototype ...




Sunday, October 17, 2010
Our jquery.js




Sunday, October 17, 2010
Back to our widget



Sunday, October 17, 2010
widget.js




Sunday, October 17, 2010
How to get this?




Sunday, October 17, 2010
Server-side




Sunday, October 17, 2010
Reading script QS




Sunday, October 17, 2010
Alternatively




Sunday, October 17, 2010
Another approach




Sunday, October 17, 2010
Getting the data



Sunday, October 17, 2010
Talking to the server




Sunday, October 17, 2010
Making the request




Sunday, October 17, 2010
Same-origin policy




Sunday, October 17, 2010
XDR flavours
                    • JSONP
                    • window.postMessage
                    • Server-side proxy
                    • url fragment (#)
                    • window.name
                    • CORS
Sunday, October 17, 2010
There’s a talk for that

                            “Breaking the Cross Domain Barrier”
                                 by Alex Sexton @ TXJS ’10

Sunday, October 17, 2010
JSONP




Sunday, October 17, 2010
JSONP




Sunday, October 17, 2010
postMessage




Sunday, October 17, 2010
postMessage


                    • Lets you send messages to windows/frames
                    • Oh, and receive them too


Sunday, October 17, 2010
postMessage big picture




Sunday, October 17, 2010
requestTalkData




Sunday, October 17, 2010
easyXDM

                    • Exposes a postMessage-like interface to
                           communicate with windows/frames
                    • But backwards compatible with older
                           browsers using whatever-works
                    • http://easyxdm.net

Sunday, October 17, 2010
Home stretch



Sunday, October 17, 2010
Render our data




Sunday, October 17, 2010
renderWidget




Sunday, October 17, 2010
cleanslate.css


                    • Like reset.css, but works on a container
                    • http://github.com/premasagar/cleanslate


Sunday, October 17, 2010
attachEvents




Sunday, October 17, 2010
Sunday, October 17, 2010
A quick note about
                                security


Sunday, October 17, 2010
What if ...




Sunday, October 17, 2010
Play it safe with iframes

                    • Don’t expose vulnerable actions on the
                           website host
                    • Hide them behind an iframe
                    • Restrict endpoint requests to originate
                           from iframe



Sunday, October 17, 2010
Sunday, October 17, 2010
Parting if-I-have-time
                                 wisdom


Sunday, October 17, 2010
Blocking scripts

                    • You can’t guarantee users will put your
                           snippet at the end of the page
                    • Their mistake, but your app’s reputation
                    • Difficult to change later


Sunday, October 17, 2010
Version like a pro

                    • You will inevitably have multiple versions
                    • Can you serve both at the same time, on
                           the same page?
                    • Getting people to upgrade is hard


Sunday, October 17, 2010
Thanks

                    • Ben Vinegar
                    • @bentlegen | http://benv.ca
                    • Disqus is hiring
                           http://disqus.com/jobs




Sunday, October 17, 2010

Contenu connexe

Tendances

Nuxeo World 2013] HOW TO CONTRIBUTE TO THE COMMUNITY - LAURENT DOGUIN
Nuxeo World 2013] HOW TO CONTRIBUTE TO THE COMMUNITY - LAURENT DOGUINNuxeo World 2013] HOW TO CONTRIBUTE TO THE COMMUNITY - LAURENT DOGUIN
Nuxeo World 2013] HOW TO CONTRIBUTE TO THE COMMUNITY - LAURENT DOGUINNuxeo
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Gitjherdman
 
RubyConf UY 2010
RubyConf UY 2010RubyConf UY 2010
RubyConf UY 2010Brian Ford
 
MySQL Sandbox - A toolkit for laziness
MySQL Sandbox - A toolkit for lazinessMySQL Sandbox - A toolkit for laziness
MySQL Sandbox - A toolkit for lazinessGiuseppe Maxia
 
Scareware Traversing the World via Ireland
Scareware Traversing the World via IrelandScareware Traversing the World via Ireland
Scareware Traversing the World via IrelandMark Hillick
 
Architecting for the Enterprise
Architecting for the EnterpriseArchitecting for the Enterprise
Architecting for the EnterpriseSencha
 

Tendances (8)

Nuxeo World 2013] HOW TO CONTRIBUTE TO THE COMMUNITY - LAURENT DOGUIN
Nuxeo World 2013] HOW TO CONTRIBUTE TO THE COMMUNITY - LAURENT DOGUINNuxeo World 2013] HOW TO CONTRIBUTE TO THE COMMUNITY - LAURENT DOGUIN
Nuxeo World 2013] HOW TO CONTRIBUTE TO THE COMMUNITY - LAURENT DOGUIN
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
RubyConf UY 2010
RubyConf UY 2010RubyConf UY 2010
RubyConf UY 2010
 
Ruby off Rails
Ruby off RailsRuby off Rails
Ruby off Rails
 
MySQL Sandbox - A toolkit for laziness
MySQL Sandbox - A toolkit for lazinessMySQL Sandbox - A toolkit for laziness
MySQL Sandbox - A toolkit for laziness
 
Scareware Traversing the World via Ireland
Scareware Traversing the World via IrelandScareware Traversing the World via Ireland
Scareware Traversing the World via Ireland
 
Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid Prototyping
 
Architecting for the Enterprise
Architecting for the EnterpriseArchitecting for the Enterprise
Architecting for the Enterprise
 

Similaire à Building Distributed JavaScript Widgets with jQuery

Human APIs - expanding the mobile web or are robots coming to JavaScript?
Human APIs - expanding the mobile web or are robots coming to JavaScript? Human APIs - expanding the mobile web or are robots coming to JavaScript?
Human APIs - expanding the mobile web or are robots coming to JavaScript? Nikolai Onken
 
When is a Website Not Enough? Now.
When is a Website Not Enough? Now.When is a Website Not Enough? Now.
When is a Website Not Enough? Now.bethgsanders
 
Unobtrusive CSS
Unobtrusive CSSUnobtrusive CSS
Unobtrusive CSSJohn Hwang
 
Creative Commons: What Every Educator Needs to Know
Creative Commons: What Every Educator Needs to KnowCreative Commons: What Every Educator Needs to Know
Creative Commons: What Every Educator Needs to KnowRodd Lucier
 
Developing Plugins on OpenVBX at Greater San Francisco Bay Area LAMP Group
Developing Plugins on OpenVBX at Greater San Francisco Bay Area LAMP GroupDeveloping Plugins on OpenVBX at Greater San Francisco Bay Area LAMP Group
Developing Plugins on OpenVBX at Greater San Francisco Bay Area LAMP Groupminddog
 
WordPress Front End Optimizations
WordPress Front End OptimizationsWordPress Front End Optimizations
WordPress Front End OptimizationsScott Taylor
 
OvertheAir 2010 html5 impact on application programming
OvertheAir 2010 html5 impact on application programmingOvertheAir 2010 html5 impact on application programming
OvertheAir 2010 html5 impact on application programmingTor Björn Minde
 
HTML5 impact on application programming
HTML5 impact on application programmingHTML5 impact on application programming
HTML5 impact on application programmingEricsson Labs
 
Debugging and Profiling Symfony Apps
Debugging and Profiling Symfony AppsDebugging and Profiling Symfony Apps
Debugging and Profiling Symfony AppsAlvaro Videla
 
QueryPath: It's like PHP jQuery in Drupal!
QueryPath: It's like PHP jQuery in Drupal!QueryPath: It's like PHP jQuery in Drupal!
QueryPath: It's like PHP jQuery in Drupal!Matt Butcher
 
Dojo Mobile
Dojo MobileDojo Mobile
Dojo Mobiledylanks
 
HTML5: Toolkits and Gaps
HTML5: Toolkits and GapsHTML5: Toolkits and Gaps
HTML5: Toolkits and Gapsdylanks
 
Debugging your JavaScript
Debugging your JavaScriptDebugging your JavaScript
Debugging your JavaScriptDiogo Antunes
 
GGUG:Practical DSL Design
GGUG:Practical DSL DesignGGUG:Practical DSL Design
GGUG:Practical DSL DesignSkills Matter
 
Mobile Development with uPortal and Infusion
Mobile Development with uPortal and InfusionMobile Development with uPortal and Infusion
Mobile Development with uPortal and Infusioncolinbdclark
 
Mobile, Media & Touch
Mobile, Media & TouchMobile, Media & Touch
Mobile, Media & TouchTim Wright
 

Similaire à Building Distributed JavaScript Widgets with jQuery (20)

Human APIs - expanding the mobile web or are robots coming to JavaScript?
Human APIs - expanding the mobile web or are robots coming to JavaScript? Human APIs - expanding the mobile web or are robots coming to JavaScript?
Human APIs - expanding the mobile web or are robots coming to JavaScript?
 
Node.js and Ruby
Node.js and RubyNode.js and Ruby
Node.js and Ruby
 
When is a Website Not Enough? Now.
When is a Website Not Enough? Now.When is a Website Not Enough? Now.
When is a Website Not Enough? Now.
 
Symfony in the Cloud
Symfony in the CloudSymfony in the Cloud
Symfony in the Cloud
 
Unobtrusive CSS
Unobtrusive CSSUnobtrusive CSS
Unobtrusive CSS
 
Creative Commons: What Every Educator Needs to Know
Creative Commons: What Every Educator Needs to KnowCreative Commons: What Every Educator Needs to Know
Creative Commons: What Every Educator Needs to Know
 
Developing Plugins on OpenVBX at Greater San Francisco Bay Area LAMP Group
Developing Plugins on OpenVBX at Greater San Francisco Bay Area LAMP GroupDeveloping Plugins on OpenVBX at Greater San Francisco Bay Area LAMP Group
Developing Plugins on OpenVBX at Greater San Francisco Bay Area LAMP Group
 
WordPress Front End Optimizations
WordPress Front End OptimizationsWordPress Front End Optimizations
WordPress Front End Optimizations
 
OvertheAir 2010 html5 impact on application programming
OvertheAir 2010 html5 impact on application programmingOvertheAir 2010 html5 impact on application programming
OvertheAir 2010 html5 impact on application programming
 
HTML5 impact on application programming
HTML5 impact on application programmingHTML5 impact on application programming
HTML5 impact on application programming
 
Debugging and Profiling Symfony Apps
Debugging and Profiling Symfony AppsDebugging and Profiling Symfony Apps
Debugging and Profiling Symfony Apps
 
QueryPath: It's like PHP jQuery in Drupal!
QueryPath: It's like PHP jQuery in Drupal!QueryPath: It's like PHP jQuery in Drupal!
QueryPath: It's like PHP jQuery in Drupal!
 
Reef - ESUG 2010
Reef - ESUG 2010Reef - ESUG 2010
Reef - ESUG 2010
 
Dojo Mobile
Dojo MobileDojo Mobile
Dojo Mobile
 
HTML5: Toolkits and Gaps
HTML5: Toolkits and GapsHTML5: Toolkits and Gaps
HTML5: Toolkits and Gaps
 
Debugging your JavaScript
Debugging your JavaScriptDebugging your JavaScript
Debugging your JavaScript
 
Human APIs
Human APIsHuman APIs
Human APIs
 
GGUG:Practical DSL Design
GGUG:Practical DSL DesignGGUG:Practical DSL Design
GGUG:Practical DSL Design
 
Mobile Development with uPortal and Infusion
Mobile Development with uPortal and InfusionMobile Development with uPortal and Infusion
Mobile Development with uPortal and Infusion
 
Mobile, Media & Touch
Mobile, Media & TouchMobile, Media & Touch
Mobile, Media & Touch
 

Dernier

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 

Dernier (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 

Building Distributed JavaScript Widgets with jQuery