SlideShare a Scribd company logo
1 of 22
Northeast JavaScript Conference #NEJSConference
Developing JavaScript
Widgets
Sometimes you have to
share the web page …
@Bob1German
Bob German
Bob is a Principal Architect at BlueMetal, where he
leads Office 365 and SharePoint development for
enterprise customers.
Cloud & Services
Content & Collaboration
Data & Analytics
Devices & Mobility
Strategy & Design
An Insight company
#NEJSConf
@Bob1German
•
•
•
•
What is a widget?
Why Widgets?
Widgets allow….
• Late integration with the hosting web page by end users
• Independent versioning of page components
• A high degree of code reuse; each widget can be tightly bound
to its JS framework and loosely bound to the page
What makes a good widget?
1 ISOLATED – so they won’t interfere with other
widgets or the rest of the page
Can you run multiple copies of the widget on a
page?
2
EFFICIENT – so they load quickly Does the page get noticeably slower as you add
widgets?
3
SELF-CONTAINED – so they’re easy to reuse Does the widget work without special page elements
such as element ID’s, scripts, and CSS references?
4 MODERN – so they’re easier to write and maintain Is the widget written in a modern JavaScript
framework such as AngularJS or Knockout?
5
CENTRALLY MANAGED – update all instances from a
single location
Do all (or many) instances of the widget work share
the same installed files?
Widgets in Action: BlueMetal Intranet
SharePoint Online using
Light Branding and Widgets
1. My Clients & Projects List
2. News Feed
3. Tabbed New Hire and Anniversary
Carousel
4. Tabbed Calendars/Discussions
5. Twitter Feed
Introducing Widget Wrangler
The "Manifesto" Why Widget Wrangler
• Has no dependencies on any other
scripts or frameworks
• Open source: Share with the
community and welcome
contributiosn
• Is easy to use
• Minimizes impact on the overall
page when several instances are
present
• Matches AngularJS 1.x browser
support
• Helps avoid interference with
the hosting page and other
widgets
• Loads scripts efficiently across all
widgets on the page
• Allows widgets written with MV*
frameworks such as AngularJS
and KnockOut, as well as plain
old javascript.
• Help isolate your code and UI for
easy portability to multiple
platforms and environments
Anatomy of a Widget
<div>
<div ng-controller="main as vm">
<h1>Hello{{vm.space()}}{{vm.name}}!</h1>
Who should I say hello to?
<input type="text" ng-model="vm.name" />
</div>
<script type="text/javascript" src="pnp-ww.js“
ww-appName="HelloApp“
ww-appType="Angular“
ww-appScripts='[{"src": “~/angular.min.js", "priority":0},
{"src": “~/script.js", "priority":1}]'>
</script>
</div>
Widget
Root
View
Widget
Wrangler
Widget Wrangler always boots to its parent element, the Widget Root.
If you boot your own widget, this HTMLElement is passed to your function.
Widget Wrangler Attributes
Tag Required Description
ww-appName yes Name for your app (need not be unique); Angular widgets boot to this module.
Can be a collection of strings to boot multiple Angular modules.
ww-appType no Currently "Angular" is the only supported framework. Widget Wrangler will boot
to one or more Angular 1.x modules when scripts are loaded.
ww-appBind no Your function to boot your widget when scripts are loaded. Use for any JS
framework.
ww-appCss no A JSON object* that defines the css files the widget needs in order to run
ww-appScripts yes A JSON object* that defines the javascript files the widget needs in order to run
[
{"src":"(script1.js)", "priority":0},
{"src": "script2.js", "priority":1}
//, …
]
* JSON object format
Priorities control
parallel vs. sequential
loading
demo
jQuery Widget
http://bit.ly/ww-jq0
http://bit.ly/ww-jq1
Anatomy of an AngularJS Widget
View
(HTML with Bindings)
Controller
manipulate objects to control the UI
Services
Web
Services
Scope or ViewModel
Widget
Directives
new elements and
attributes
Web Page
Module
@BASPUG
@Bob1Germa
n
@jfj1997
demo
Angular Widgets
Hello World - http://bit.ly/ww-ng1-1
Weather Forecast - http://bit.ly/ww-ng1-2
Connected Widgets - http://bit.ly/ww-ng1-3
demo
Other Frameworks
Knockout - http://bit.ly/ww-ko1
Plain JavaScript - http://bit.ly/ww-jq1
Angular 2 - http://bit.ly/ww-ng2-1
demo
Testing Widget Wrangler
http://bit.ly/ww-tester
Deploying Widgets
• Put as much as possible in a CDN or other shared
location so it can be updated centrally
• Put as little as possible on the target web sites
that will run the widget
Distribution
CDN or other
Shared Location
Target Site
JS Bundles
JavaScript
HTML templates
CSS
Minimum needed
to host the widget
Cross-Origin Resource Sharing
https://www.evilkittens.com/Get page HTML
Request page HTML
https://www.mybank.com/Do an AJAX request
X
BLOCKED!
Get the JavaScript
Request some JavaScript
https://www.cdn.com/
• Scripts, CSS, and Images referenced by HTML are
no problem
• AJAX requests across domain names are not
allowed by default
Cross-Origin Resource Sharing
https://www.evilkittens.com/Get page HTML
Request page HTML
https://www.mybank.com/
Get the JavaScript
Request some JavaScript
https://www.cdn.com/
Preflight request
Cross-origin Policy
Do an AJAX request
Get the Data
“No, really, it’s OK to accept cross-
origin requests from evilkittens.com!”
Do an AJAX request
X
BLOCKED!
• Common examples:
• Calling web services
• Reading HTML templates
WidgetBundling
In general, bundling is good
• Faster load times
• Automatically versions all assets
consistently
• Synchronous loads
Caveat for widgets
• Consider not (or separately)
bundling assets shared by other
widgets
.ts
.ts
.js
.html
.less
Bundler
0: javascript
Compilers
(.ts  .js,
.less 
.css)
Task runner
1: javascript
2: javascript
(html in
string)
3: javascript
4: javascript
(css in string)
Javascript
bundle
Source Files
Widget Wrangler Backlog
• Framework detection (avoid loading twice – maybe with
version checking)
• Framework Overloading (e.g. multiple versions of jQuery or
Angular on the page)
• Angular 2.0 support
• Diagnostic widget you can add to a page to show load
sequence, timings, and exceptions
• IE 8 support (to have parity with SharePoint 2013 browser
support)
Resources
Widget Wrangler
• http://bit.ly/ww-github
• http://bit.ly/ww-intro
Widget Samples
• Angular 1 (Simple) – http://bit.ly/ww-ng1-1
• Angular 1 (Weather) – http://bit.ly/ww-ng1-2
• Angular 1 (Connected) – http://bit.ly/ww-ng1-3
• Angular 2 – http://bit.ly/ww-ng2-1
• jQuery – http://bit.ly/ww-jq1
• Knockout – http://bit.ly/ww-ko1
• Plain JS – http://bit.ly/ww-js1
thank
you

More Related Content

What's hot

Server rendering-talk
Server rendering-talkServer rendering-talk
Server rendering-talkDaiwei Lu
 
Making Single Page Applications (SPA) faster
Making Single Page Applications (SPA) faster Making Single Page Applications (SPA) faster
Making Single Page Applications (SPA) faster Boris Livshutz
 
Pros and Cons of developing a Thick Clientside App
Pros and Cons of developing a Thick Clientside AppPros and Cons of developing a Thick Clientside App
Pros and Cons of developing a Thick Clientside AppRavi Teja
 
Evaluating and Choosing ZK Framework
Evaluating and Choosing ZK FrameworkEvaluating and Choosing ZK Framework
Evaluating and Choosing ZK Frameworksoutherncrossie
 
I gov. организация-фронтед-части.
I gov. организация-фронтед-части.I gov. организация-фронтед-части.
I gov. организация-фронтед-части.vasya_bh
 
LESS is More (ChiHTML5 Meetup June 2016)
LESS is More (ChiHTML5 Meetup June 2016)LESS is More (ChiHTML5 Meetup June 2016)
LESS is More (ChiHTML5 Meetup June 2016)Sara Laupp
 
A Simpler Web App Architecture (jDays 2016)
A Simpler Web App Architecture (jDays 2016)A Simpler Web App Architecture (jDays 2016)
A Simpler Web App Architecture (jDays 2016)Gustaf Nilsson Kotte
 
Single page applications
Single page applicationsSingle page applications
Single page applicationsDiego Cardozo
 
Single Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJSSingle Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJSM R Rony
 
Rise of the responsive single page application
Rise of the responsive single page applicationRise of the responsive single page application
Rise of the responsive single page applicationOren Shatken
 
Single Page Application Development with backbone.js and Simple.Web
Single Page Application Development with backbone.js and Simple.WebSingle Page Application Development with backbone.js and Simple.Web
Single Page Application Development with backbone.js and Simple.WebChris Canal
 
Building a Single-Page App: Backbone, Node.js, and Beyond
Building a Single-Page App: Backbone, Node.js, and BeyondBuilding a Single-Page App: Backbone, Node.js, and Beyond
Building a Single-Page App: Backbone, Node.js, and BeyondSpike Brehm
 
Client Vs. Server Rendering
Client Vs. Server RenderingClient Vs. Server Rendering
Client Vs. Server RenderingDavid Amend
 
Advanced front end debugging with ms edge and ms tools
Advanced front end debugging with ms edge and ms toolsAdvanced front end debugging with ms edge and ms tools
Advanced front end debugging with ms edge and ms toolsChris Love
 
Introduction to Vue.js DevStaff Meetup 13.02
Introduction to Vue.js  DevStaff Meetup 13.02Introduction to Vue.js  DevStaff Meetup 13.02
Introduction to Vue.js DevStaff Meetup 13.02Paul Bele
 
A High-Performance Solution To Microservices UI Composition
A High-Performance Solution To Microservices UI CompositionA High-Performance Solution To Microservices UI Composition
A High-Performance Solution To Microservices UI CompositionAlexey Gravanov
 
Polymer / WebComponents
Polymer / WebComponentsPolymer / WebComponents
Polymer / WebComponentsArnaud Kervern
 
Building web applications using kendo ui and the mvvm pattern
Building web applications using kendo ui and the mvvm patternBuilding web applications using kendo ui and the mvvm pattern
Building web applications using kendo ui and the mvvm patternAspenware
 

What's hot (20)

Server rendering-talk
Server rendering-talkServer rendering-talk
Server rendering-talk
 
Codegen2021 blazor mobile
Codegen2021 blazor mobileCodegen2021 blazor mobile
Codegen2021 blazor mobile
 
Booting up with polymer
Booting up with polymerBooting up with polymer
Booting up with polymer
 
Making Single Page Applications (SPA) faster
Making Single Page Applications (SPA) faster Making Single Page Applications (SPA) faster
Making Single Page Applications (SPA) faster
 
Pros and Cons of developing a Thick Clientside App
Pros and Cons of developing a Thick Clientside AppPros and Cons of developing a Thick Clientside App
Pros and Cons of developing a Thick Clientside App
 
Evaluating and Choosing ZK Framework
Evaluating and Choosing ZK FrameworkEvaluating and Choosing ZK Framework
Evaluating and Choosing ZK Framework
 
I gov. организация-фронтед-части.
I gov. организация-фронтед-части.I gov. организация-фронтед-части.
I gov. организация-фронтед-части.
 
LESS is More (ChiHTML5 Meetup June 2016)
LESS is More (ChiHTML5 Meetup June 2016)LESS is More (ChiHTML5 Meetup June 2016)
LESS is More (ChiHTML5 Meetup June 2016)
 
A Simpler Web App Architecture (jDays 2016)
A Simpler Web App Architecture (jDays 2016)A Simpler Web App Architecture (jDays 2016)
A Simpler Web App Architecture (jDays 2016)
 
Single page applications
Single page applicationsSingle page applications
Single page applications
 
Single Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJSSingle Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJS
 
Rise of the responsive single page application
Rise of the responsive single page applicationRise of the responsive single page application
Rise of the responsive single page application
 
Single Page Application Development with backbone.js and Simple.Web
Single Page Application Development with backbone.js and Simple.WebSingle Page Application Development with backbone.js and Simple.Web
Single Page Application Development with backbone.js and Simple.Web
 
Building a Single-Page App: Backbone, Node.js, and Beyond
Building a Single-Page App: Backbone, Node.js, and BeyondBuilding a Single-Page App: Backbone, Node.js, and Beyond
Building a Single-Page App: Backbone, Node.js, and Beyond
 
Client Vs. Server Rendering
Client Vs. Server RenderingClient Vs. Server Rendering
Client Vs. Server Rendering
 
Advanced front end debugging with ms edge and ms tools
Advanced front end debugging with ms edge and ms toolsAdvanced front end debugging with ms edge and ms tools
Advanced front end debugging with ms edge and ms tools
 
Introduction to Vue.js DevStaff Meetup 13.02
Introduction to Vue.js  DevStaff Meetup 13.02Introduction to Vue.js  DevStaff Meetup 13.02
Introduction to Vue.js DevStaff Meetup 13.02
 
A High-Performance Solution To Microservices UI Composition
A High-Performance Solution To Microservices UI CompositionA High-Performance Solution To Microservices UI Composition
A High-Performance Solution To Microservices UI Composition
 
Polymer / WebComponents
Polymer / WebComponentsPolymer / WebComponents
Polymer / WebComponents
 
Building web applications using kendo ui and the mvvm pattern
Building web applications using kendo ui and the mvvm patternBuilding web applications using kendo ui and the mvvm pattern
Building web applications using kendo ui and the mvvm pattern
 

Similar to Developing JavaScript Widgets

Building a website without a webserver on Azure
Building a website without a webserver on AzureBuilding a website without a webserver on Azure
Building a website without a webserver on AzureTodd Whitehead
 
Responsivedesign 7-3-2012
Responsivedesign 7-3-2012Responsivedesign 7-3-2012
Responsivedesign 7-3-2012Thomas Carney
 
Developing High Performance Web Apps
Developing High Performance Web AppsDeveloping High Performance Web Apps
Developing High Performance Web AppsTimothy Fisher
 
Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011Timothy Fisher
 
Introduction to Jquery
Introduction to JqueryIntroduction to Jquery
Introduction to JqueryGurpreet singh
 
Typescript 102 angular and type script
Typescript 102   angular and type scriptTypescript 102   angular and type script
Typescript 102 angular and type scriptBob German
 
Web Usability
Web UsabilityWeb Usability
Web UsabilityWilson Su
 
Deep dive into share point framework webparts
Deep dive into share point framework webpartsDeep dive into share point framework webparts
Deep dive into share point framework webpartsPrabhu Nehru
 
Introduction to Client Side Dev in SharePoint Workshop
Introduction to Client Side Dev in SharePoint WorkshopIntroduction to Client Side Dev in SharePoint Workshop
Introduction to Client Side Dev in SharePoint WorkshopMark Rackley
 
HTML5 and CSS3 refresher
HTML5 and CSS3 refresherHTML5 and CSS3 refresher
HTML5 and CSS3 refresherIvano Malavolta
 
From server generated pages to client app in a micro-services world
From server generated pages to client app in a micro-services worldFrom server generated pages to client app in a micro-services world
From server generated pages to client app in a micro-services worldAssaf Gannon
 
A Day Building Fast, Responsive, Extensible Single Page Applications
A Day Building Fast, Responsive, Extensible Single Page ApplicationsA Day Building Fast, Responsive, Extensible Single Page Applications
A Day Building Fast, Responsive, Extensible Single Page ApplicationsChris Love
 

Similar to Developing JavaScript Widgets (20)

Building a website without a webserver on Azure
Building a website without a webserver on AzureBuilding a website without a webserver on Azure
Building a website without a webserver on Azure
 
Responsivedesign 7-3-2012
Responsivedesign 7-3-2012Responsivedesign 7-3-2012
Responsivedesign 7-3-2012
 
Developing High Performance Web Apps
Developing High Performance Web AppsDeveloping High Performance Web Apps
Developing High Performance Web Apps
 
Ui dev@naukri-2011
Ui dev@naukri-2011Ui dev@naukri-2011
Ui dev@naukri-2011
 
Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011
 
Sai Sharan_UI_Resume
Sai Sharan_UI_ResumeSai Sharan_UI_Resume
Sai Sharan_UI_Resume
 
Web summit.pptx
Web summit.pptxWeb summit.pptx
Web summit.pptx
 
wt mod3.pdf
wt mod3.pdfwt mod3.pdf
wt mod3.pdf
 
Introduction to Jquery
Introduction to JqueryIntroduction to Jquery
Introduction to Jquery
 
Typescript 102 angular and type script
Typescript 102   angular and type scriptTypescript 102   angular and type script
Typescript 102 angular and type script
 
Web Desing.pptx
Web Desing.pptxWeb Desing.pptx
Web Desing.pptx
 
Web Usability
Web UsabilityWeb Usability
Web Usability
 
Deep dive into share point framework webparts
Deep dive into share point framework webpartsDeep dive into share point framework webparts
Deep dive into share point framework webparts
 
Introduction to Client Side Dev in SharePoint Workshop
Introduction to Client Side Dev in SharePoint WorkshopIntroduction to Client Side Dev in SharePoint Workshop
Introduction to Client Side Dev in SharePoint Workshop
 
Santosh_Resume_Java
Santosh_Resume_JavaSantosh_Resume_Java
Santosh_Resume_Java
 
Automated UI Testing
Automated UI TestingAutomated UI Testing
Automated UI Testing
 
HTML5 and CSS3 refresher
HTML5 and CSS3 refresherHTML5 and CSS3 refresher
HTML5 and CSS3 refresher
 
From server generated pages to client app in a micro-services world
From server generated pages to client app in a micro-services worldFrom server generated pages to client app in a micro-services world
From server generated pages to client app in a micro-services world
 
Transforming the web into a real application platform
Transforming the web into a real application platformTransforming the web into a real application platform
Transforming the web into a real application platform
 
A Day Building Fast, Responsive, Extensible Single Page Applications
A Day Building Fast, Responsive, Extensible Single Page ApplicationsA Day Building Fast, Responsive, Extensible Single Page Applications
A Day Building Fast, Responsive, Extensible Single Page Applications
 

More from Bob German

Introduction to the Microsoft Bot Framework v4
Introduction to the Microsoft Bot Framework v4Introduction to the Microsoft Bot Framework v4
Introduction to the Microsoft Bot Framework v4Bob German
 
Adaptive cards 101
Adaptive cards 101Adaptive cards 101
Adaptive cards 101Bob German
 
Introduction to Teams Development - North American Collaboration Summit
Introduction to Teams Development - North American Collaboration SummitIntroduction to Teams Development - North American Collaboration Summit
Introduction to Teams Development - North American Collaboration SummitBob German
 
Future-proof Development for Classic SharePoint
Future-proof Development for Classic SharePointFuture-proof Development for Classic SharePoint
Future-proof Development for Classic SharePointBob German
 
Azure for SharePoint Developers - Workshop - Part 4: Bots
Azure for SharePoint Developers - Workshop - Part 4: BotsAzure for SharePoint Developers - Workshop - Part 4: Bots
Azure for SharePoint Developers - Workshop - Part 4: BotsBob German
 
Azure for SharePoint Developers - Workshop - Part 3: Web Services
Azure for SharePoint Developers - Workshop - Part 3: Web ServicesAzure for SharePoint Developers - Workshop - Part 3: Web Services
Azure for SharePoint Developers - Workshop - Part 3: Web ServicesBob German
 
Azure for SharePoint Developers - Workshop - Part 2: Azure Functions
Azure for SharePoint Developers - Workshop - Part 2: Azure FunctionsAzure for SharePoint Developers - Workshop - Part 2: Azure Functions
Azure for SharePoint Developers - Workshop - Part 2: Azure FunctionsBob German
 
Azure for SharePoint Developers - Workshop - Part 1: Azure AD
Azure for SharePoint Developers - Workshop - Part 1: Azure ADAzure for SharePoint Developers - Workshop - Part 1: Azure AD
Azure for SharePoint Developers - Workshop - Part 1: Azure ADBob German
 
Azure for SharePoint Developers - Workshop - Part 5: Logic Apps
Azure for SharePoint Developers - Workshop - Part 5: Logic AppsAzure for SharePoint Developers - Workshop - Part 5: Logic Apps
Azure for SharePoint Developers - Workshop - Part 5: Logic AppsBob German
 
Azure AD for browser-based application developers
Azure AD for browser-based application developersAzure AD for browser-based application developers
Azure AD for browser-based application developersBob German
 
Mastering Azure Functions
Mastering Azure FunctionsMastering Azure Functions
Mastering Azure FunctionsBob German
 
Going with the Flow: Rationalizing the workflow options in SharePoint Online
Going with the Flow: Rationalizing the workflow options in SharePoint OnlineGoing with the Flow: Rationalizing the workflow options in SharePoint Online
Going with the Flow: Rationalizing the workflow options in SharePoint OnlineBob German
 
Modern SharePoint, the Good, the Bad, and the Ugly
Modern SharePoint, the Good, the Bad, and the UglyModern SharePoint, the Good, the Bad, and the Ugly
Modern SharePoint, the Good, the Bad, and the UglyBob German
 
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScriptBob German
 
TypeScript and SharePoint Framework
TypeScript and SharePoint FrameworkTypeScript and SharePoint Framework
TypeScript and SharePoint FrameworkBob German
 
German introduction to sp framework
German   introduction to sp frameworkGerman   introduction to sp framework
German introduction to sp frameworkBob German
 
SPSNYC - Next Generation Portals
SPSNYC - Next Generation PortalsSPSNYC - Next Generation Portals
SPSNYC - Next Generation PortalsBob German
 
Typescript 101 introduction
Typescript 101   introductionTypescript 101   introduction
Typescript 101 introductionBob German
 
Search First Migration - Using SharePoint 2013 Search for SharePoint 2010
Search First Migration - Using SharePoint 2013 Search for SharePoint 2010Search First Migration - Using SharePoint 2013 Search for SharePoint 2010
Search First Migration - Using SharePoint 2013 Search for SharePoint 2010Bob German
 
Enterprise Content Management + SharePoint 2013 - SPSNH
Enterprise Content Management + SharePoint 2013 - SPSNHEnterprise Content Management + SharePoint 2013 - SPSNH
Enterprise Content Management + SharePoint 2013 - SPSNHBob German
 

More from Bob German (20)

Introduction to the Microsoft Bot Framework v4
Introduction to the Microsoft Bot Framework v4Introduction to the Microsoft Bot Framework v4
Introduction to the Microsoft Bot Framework v4
 
Adaptive cards 101
Adaptive cards 101Adaptive cards 101
Adaptive cards 101
 
Introduction to Teams Development - North American Collaboration Summit
Introduction to Teams Development - North American Collaboration SummitIntroduction to Teams Development - North American Collaboration Summit
Introduction to Teams Development - North American Collaboration Summit
 
Future-proof Development for Classic SharePoint
Future-proof Development for Classic SharePointFuture-proof Development for Classic SharePoint
Future-proof Development for Classic SharePoint
 
Azure for SharePoint Developers - Workshop - Part 4: Bots
Azure for SharePoint Developers - Workshop - Part 4: BotsAzure for SharePoint Developers - Workshop - Part 4: Bots
Azure for SharePoint Developers - Workshop - Part 4: Bots
 
Azure for SharePoint Developers - Workshop - Part 3: Web Services
Azure for SharePoint Developers - Workshop - Part 3: Web ServicesAzure for SharePoint Developers - Workshop - Part 3: Web Services
Azure for SharePoint Developers - Workshop - Part 3: Web Services
 
Azure for SharePoint Developers - Workshop - Part 2: Azure Functions
Azure for SharePoint Developers - Workshop - Part 2: Azure FunctionsAzure for SharePoint Developers - Workshop - Part 2: Azure Functions
Azure for SharePoint Developers - Workshop - Part 2: Azure Functions
 
Azure for SharePoint Developers - Workshop - Part 1: Azure AD
Azure for SharePoint Developers - Workshop - Part 1: Azure ADAzure for SharePoint Developers - Workshop - Part 1: Azure AD
Azure for SharePoint Developers - Workshop - Part 1: Azure AD
 
Azure for SharePoint Developers - Workshop - Part 5: Logic Apps
Azure for SharePoint Developers - Workshop - Part 5: Logic AppsAzure for SharePoint Developers - Workshop - Part 5: Logic Apps
Azure for SharePoint Developers - Workshop - Part 5: Logic Apps
 
Azure AD for browser-based application developers
Azure AD for browser-based application developersAzure AD for browser-based application developers
Azure AD for browser-based application developers
 
Mastering Azure Functions
Mastering Azure FunctionsMastering Azure Functions
Mastering Azure Functions
 
Going with the Flow: Rationalizing the workflow options in SharePoint Online
Going with the Flow: Rationalizing the workflow options in SharePoint OnlineGoing with the Flow: Rationalizing the workflow options in SharePoint Online
Going with the Flow: Rationalizing the workflow options in SharePoint Online
 
Modern SharePoint, the Good, the Bad, and the Ugly
Modern SharePoint, the Good, the Bad, and the UglyModern SharePoint, the Good, the Bad, and the Ugly
Modern SharePoint, the Good, the Bad, and the Ugly
 
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScript
 
TypeScript and SharePoint Framework
TypeScript and SharePoint FrameworkTypeScript and SharePoint Framework
TypeScript and SharePoint Framework
 
German introduction to sp framework
German   introduction to sp frameworkGerman   introduction to sp framework
German introduction to sp framework
 
SPSNYC - Next Generation Portals
SPSNYC - Next Generation PortalsSPSNYC - Next Generation Portals
SPSNYC - Next Generation Portals
 
Typescript 101 introduction
Typescript 101   introductionTypescript 101   introduction
Typescript 101 introduction
 
Search First Migration - Using SharePoint 2013 Search for SharePoint 2010
Search First Migration - Using SharePoint 2013 Search for SharePoint 2010Search First Migration - Using SharePoint 2013 Search for SharePoint 2010
Search First Migration - Using SharePoint 2013 Search for SharePoint 2010
 
Enterprise Content Management + SharePoint 2013 - SPSNH
Enterprise Content Management + SharePoint 2013 - SPSNHEnterprise Content Management + SharePoint 2013 - SPSNH
Enterprise Content Management + SharePoint 2013 - SPSNH
 

Recently uploaded

Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 

Recently uploaded (20)

Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 

Developing JavaScript Widgets

  • 1. Northeast JavaScript Conference #NEJSConference Developing JavaScript Widgets Sometimes you have to share the web page … @Bob1German
  • 2. Bob German Bob is a Principal Architect at BlueMetal, where he leads Office 365 and SharePoint development for enterprise customers. Cloud & Services Content & Collaboration Data & Analytics Devices & Mobility Strategy & Design An Insight company #NEJSConf @Bob1German
  • 4. Why Widgets? Widgets allow…. • Late integration with the hosting web page by end users • Independent versioning of page components • A high degree of code reuse; each widget can be tightly bound to its JS framework and loosely bound to the page
  • 5. What makes a good widget? 1 ISOLATED – so they won’t interfere with other widgets or the rest of the page Can you run multiple copies of the widget on a page? 2 EFFICIENT – so they load quickly Does the page get noticeably slower as you add widgets? 3 SELF-CONTAINED – so they’re easy to reuse Does the widget work without special page elements such as element ID’s, scripts, and CSS references? 4 MODERN – so they’re easier to write and maintain Is the widget written in a modern JavaScript framework such as AngularJS or Knockout? 5 CENTRALLY MANAGED – update all instances from a single location Do all (or many) instances of the widget work share the same installed files?
  • 6. Widgets in Action: BlueMetal Intranet SharePoint Online using Light Branding and Widgets 1. My Clients & Projects List 2. News Feed 3. Tabbed New Hire and Anniversary Carousel 4. Tabbed Calendars/Discussions 5. Twitter Feed
  • 7. Introducing Widget Wrangler The "Manifesto" Why Widget Wrangler • Has no dependencies on any other scripts or frameworks • Open source: Share with the community and welcome contributiosn • Is easy to use • Minimizes impact on the overall page when several instances are present • Matches AngularJS 1.x browser support • Helps avoid interference with the hosting page and other widgets • Loads scripts efficiently across all widgets on the page • Allows widgets written with MV* frameworks such as AngularJS and KnockOut, as well as plain old javascript. • Help isolate your code and UI for easy portability to multiple platforms and environments
  • 8. Anatomy of a Widget <div> <div ng-controller="main as vm"> <h1>Hello{{vm.space()}}{{vm.name}}!</h1> Who should I say hello to? <input type="text" ng-model="vm.name" /> </div> <script type="text/javascript" src="pnp-ww.js“ ww-appName="HelloApp“ ww-appType="Angular“ ww-appScripts='[{"src": “~/angular.min.js", "priority":0}, {"src": “~/script.js", "priority":1}]'> </script> </div> Widget Root View Widget Wrangler Widget Wrangler always boots to its parent element, the Widget Root. If you boot your own widget, this HTMLElement is passed to your function.
  • 9. Widget Wrangler Attributes Tag Required Description ww-appName yes Name for your app (need not be unique); Angular widgets boot to this module. Can be a collection of strings to boot multiple Angular modules. ww-appType no Currently "Angular" is the only supported framework. Widget Wrangler will boot to one or more Angular 1.x modules when scripts are loaded. ww-appBind no Your function to boot your widget when scripts are loaded. Use for any JS framework. ww-appCss no A JSON object* that defines the css files the widget needs in order to run ww-appScripts yes A JSON object* that defines the javascript files the widget needs in order to run [ {"src":"(script1.js)", "priority":0}, {"src": "script2.js", "priority":1} //, … ] * JSON object format Priorities control parallel vs. sequential loading
  • 11. Anatomy of an AngularJS Widget View (HTML with Bindings) Controller manipulate objects to control the UI Services Web Services Scope or ViewModel Widget Directives new elements and attributes Web Page Module @BASPUG @Bob1Germa n @jfj1997
  • 12. demo Angular Widgets Hello World - http://bit.ly/ww-ng1-1 Weather Forecast - http://bit.ly/ww-ng1-2 Connected Widgets - http://bit.ly/ww-ng1-3
  • 13. demo Other Frameworks Knockout - http://bit.ly/ww-ko1 Plain JavaScript - http://bit.ly/ww-jq1 Angular 2 - http://bit.ly/ww-ng2-1
  • 15.
  • 16. Deploying Widgets • Put as much as possible in a CDN or other shared location so it can be updated centrally • Put as little as possible on the target web sites that will run the widget Distribution CDN or other Shared Location Target Site JS Bundles JavaScript HTML templates CSS Minimum needed to host the widget
  • 17. Cross-Origin Resource Sharing https://www.evilkittens.com/Get page HTML Request page HTML https://www.mybank.com/Do an AJAX request X BLOCKED! Get the JavaScript Request some JavaScript https://www.cdn.com/ • Scripts, CSS, and Images referenced by HTML are no problem • AJAX requests across domain names are not allowed by default
  • 18. Cross-Origin Resource Sharing https://www.evilkittens.com/Get page HTML Request page HTML https://www.mybank.com/ Get the JavaScript Request some JavaScript https://www.cdn.com/ Preflight request Cross-origin Policy Do an AJAX request Get the Data “No, really, it’s OK to accept cross- origin requests from evilkittens.com!” Do an AJAX request X BLOCKED! • Common examples: • Calling web services • Reading HTML templates
  • 19. WidgetBundling In general, bundling is good • Faster load times • Automatically versions all assets consistently • Synchronous loads Caveat for widgets • Consider not (or separately) bundling assets shared by other widgets .ts .ts .js .html .less Bundler 0: javascript Compilers (.ts  .js, .less  .css) Task runner 1: javascript 2: javascript (html in string) 3: javascript 4: javascript (css in string) Javascript bundle Source Files
  • 20. Widget Wrangler Backlog • Framework detection (avoid loading twice – maybe with version checking) • Framework Overloading (e.g. multiple versions of jQuery or Angular on the page) • Angular 2.0 support • Diagnostic widget you can add to a page to show load sequence, timings, and exceptions • IE 8 support (to have parity with SharePoint 2013 browser support)
  • 21. Resources Widget Wrangler • http://bit.ly/ww-github • http://bit.ly/ww-intro Widget Samples • Angular 1 (Simple) – http://bit.ly/ww-ng1-1 • Angular 1 (Weather) – http://bit.ly/ww-ng1-2 • Angular 1 (Connected) – http://bit.ly/ww-ng1-3 • Angular 2 – http://bit.ly/ww-ng2-1 • jQuery – http://bit.ly/ww-jq1 • Knockout – http://bit.ly/ww-ko1 • Plain JS – http://bit.ly/ww-js1