SlideShare une entreprise Scribd logo
1  sur  31
Creating Modular 
WebParts with RequireJS 
in SharePoint 
Dog Food Conference 
Tuesday, September 30th, 2014 
Christopher Fahey
About 
Developer at Cardinal Solutions Group 
Doing SharePoint development for over 2 years 
Two Scrum certifications 
PSM, PSD 
Two Microsoft certifications 
70-480, 70-486
Logistics 
Use Hubb.me to schedule a one on one with me 
http://dogfoodcon.hubb.me 
Tweet at Dog Food 
https://twitter.com/hashtag/DogFoodCon 
#DogFoodCon @DogFoodCon 
Principles apply to various platforms/solutions 
Interactive presentation - ask questions during
Goals 
Assuming everyone is a developer 
Beneficial and learn something as IT Pro, Manger, etc. 
Start building front-end solutions using RequireJS 
Encourage development of modular code
What is RequireJS?
Front end file and module loader 
AMD - Asynchronous Module Definition 
What are JavaScript modules? 
Encapsulate code into useful units and then expose its 
data and behavior 
Optimization tool
Why RequireJS?
Large project have many files in which 
managing the dependencies for each file 
becomes cumbersome 
Having to write many script tags is not scalable 
Easy to load scripts on demand 
References to other dependencies are done via 
global variables - often implicitly
“Unmanageable” Scripts
Pro Tip 
“ 
Implied global 
variables should never 
be used. Use of 
global variables should 
be minimized. 
Douglas Crockford 
” 
http://javascript.crockford.com/code.html
Why Start Using RequireJS 
Many popular libraries already work with 
RequireJS 
Decouples your 
applications 
Ease of 
maintenance
Distinct functionality 
Small, single purpose scripts 
Single Responsibility (SOLID) 
Divide and conquer large applications into small blocks 
Helps manage dependencies 
Microsoft is pushing development towards front-end 
coded solutions in SharePoint
Doing things the app way 
“ 
Custom code that runs 
on the SharePoint 
servers is not allowed in 
Apps for SharePoint. 
MSDN 
” 
http://msdn.microsoft.com/en-us/library/office/jj163114(v=office.15).aspx
Learning RequireJS
RequireJS Basics 
● Three global variables 
○ window.define(); 
○ window.require(); 
○ window.requirejs; 
● Assumes all scripts are in the /scripts directory 
● The .js file extension is assumed 
● Browser support back to IE6 and Firefox 2
require() 
specify any 
dependencies 
runs like an 
immediate function 
require([“welcome”], function (welcome) { 
welcome.showTodaysDate(); 
welcome.greetUser(); 
});
define() 
define() states we are 
creating module and 
using jQuery 
returns an object that 
exposes the desired 
data and behavior 
define([“jquery”], function ($) { 
var todaysDate = new Date(); 
return { 
today: todaysDate, 
showTodaysDate: function() { 
$(“.todays-date”).text(todaysDate); 
}, 
greetUser: function () { 
$(“.welcome”).text(“Hi”); 
} 
}; 
});
configs() 
baseUrl is the root 
path for all module 
lookups 
paths is a mapping of 
urls for any module 
names 
shims helps manage 
dependencies of 
scripts 
many more 
configuration options 
require.config({ 
baseUrl: “/Style Library”, 
paths: { 
“jquery”: “jquery.1.7.1”, 
“u”: “underscore.1.7.0” 
}, 
shims: { 
“backbone”: { 
deps: [“jquery”, “u”] 
} 
} 
});
RequireJS In SharePoint
Creating a WebPart 
Create a new SharePoint 2013 Project 
Deploy as Sandbox Solution 
Create a Visual WebPart 
Add Scripts leveraging RequireJS
WebPart
Project Setup
User Control
Lazy Loading Scripts
Lazy Loading Scripts (continued) 
Charts.js file was not downloaded until “Show All Data” 
button was clicked - about 20 seconds after page load
Lessons Learned 
Very quick and easy to start using RequireJS, 
but unlikely current code base will “just work” 
Figure out a pattern and stick with it 
Naming 
Keep files small, do one thing at a time
Example
Testing Example
Resources 
http://requirejs.org 
http://addyosmani.com/writing-modular-js 
http://blog.teamtreehouse.com/organize-your-code- 
with-requirejs 
http://youtube.com/watch?v=eRqsZqLyYaU
Discussion 
Slides 
http://www.slideshare.net/fahey252 
Connect 
https://www.linkedin.com/in/christopherpatrickfahey 
Schedule a one on one 
http://dogfoodcon.hubb.me

Contenu connexe

Tendances

Александр Белецкий "Архитектура Javascript приложений"
 Александр Белецкий "Архитектура Javascript приложений" Александр Белецкий "Архитектура Javascript приложений"
Александр Белецкий "Архитектура Javascript приложений"Agile Base Camp
 
The Javascript Toolkit 2.0
The Javascript Toolkit 2.0The Javascript Toolkit 2.0
The Javascript Toolkit 2.0Marcos Vinícius
 
Mastering react with redux
Mastering react with reduxMastering react with redux
Mastering react with reduxGaurav Singh
 
CreateJS hackathon in Zurich
CreateJS hackathon in ZurichCreateJS hackathon in Zurich
CreateJS hackathon in ZurichHenri Bergius
 
Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...
Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...
Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...DicodingEvent
 
Decoupling Content Management with Create.js
Decoupling Content Management with Create.jsDecoupling Content Management with Create.js
Decoupling Content Management with Create.jsHenri Bergius
 
JEE Conf 2015: Less JS!
JEE Conf 2015: Less JS!JEE Conf 2015: Less JS!
JEE Conf 2015: Less JS!_Dewy_
 
Blast Mojo Overview
Blast Mojo OverviewBlast Mojo Overview
Blast Mojo Overviewloyalchow
 
Tech talk live share extras extension modules feb 13
Tech talk live   share extras extension modules feb 13Tech talk live   share extras extension modules feb 13
Tech talk live share extras extension modules feb 13Alfresco Software
 
Introduction:
Introduction:Introduction:
Introduction:Reema
 
Introduction to Modern and Emerging Web Technologies
Introduction to Modern and Emerging Web TechnologiesIntroduction to Modern and Emerging Web Technologies
Introduction to Modern and Emerging Web TechnologiesSuresh Patidar
 
The Complete React Learning Course
The Complete React Learning CourseThe Complete React Learning Course
The Complete React Learning CourseRakhi Lambha
 
Nuxt.JS Introdruction
Nuxt.JS IntrodructionNuxt.JS Introdruction
Nuxt.JS IntrodructionDavid Ličen
 
Free Online SharePoint Framework Webinar
Free Online SharePoint Framework WebinarFree Online SharePoint Framework Webinar
Free Online SharePoint Framework WebinarManoj Mittal
 
Using an in-house WordPress framework
Using an  in-house WordPress frameworkUsing an  in-house WordPress framework
Using an in-house WordPress frameworkpeterwilsoncc
 

Tendances (20)

Александр Белецкий "Архитектура Javascript приложений"
 Александр Белецкий "Архитектура Javascript приложений" Александр Белецкий "Архитектура Javascript приложений"
Александр Белецкий "Архитектура Javascript приложений"
 
The Javascript Toolkit 2.0
The Javascript Toolkit 2.0The Javascript Toolkit 2.0
The Javascript Toolkit 2.0
 
Mastering react with redux
Mastering react with reduxMastering react with redux
Mastering react with redux
 
CreateJS hackathon in Zurich
CreateJS hackathon in ZurichCreateJS hackathon in Zurich
CreateJS hackathon in Zurich
 
Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...
Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...
Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...
 
Decoupling Content Management with Create.js
Decoupling Content Management with Create.jsDecoupling Content Management with Create.js
Decoupling Content Management with Create.js
 
JEE Conf 2015: Less JS!
JEE Conf 2015: Less JS!JEE Conf 2015: Less JS!
JEE Conf 2015: Less JS!
 
Blast Mojo Overview
Blast Mojo OverviewBlast Mojo Overview
Blast Mojo Overview
 
Tech talk live share extras extension modules feb 13
Tech talk live   share extras extension modules feb 13Tech talk live   share extras extension modules feb 13
Tech talk live share extras extension modules feb 13
 
Introduction:
Introduction:Introduction:
Introduction:
 
Difference between-angular js-nodejs
Difference between-angular js-nodejsDifference between-angular js-nodejs
Difference between-angular js-nodejs
 
Enterprise Griffon
Enterprise GriffonEnterprise Griffon
Enterprise Griffon
 
Introduction to Modern and Emerging Web Technologies
Introduction to Modern and Emerging Web TechnologiesIntroduction to Modern and Emerging Web Technologies
Introduction to Modern and Emerging Web Technologies
 
The Complete React Learning Course
The Complete React Learning CourseThe Complete React Learning Course
The Complete React Learning Course
 
XEclipse
XEclipseXEclipse
XEclipse
 
Jquery
JqueryJquery
Jquery
 
jQuery templates
jQuery templatesjQuery templates
jQuery templates
 
Nuxt.JS Introdruction
Nuxt.JS IntrodructionNuxt.JS Introdruction
Nuxt.JS Introdruction
 
Free Online SharePoint Framework Webinar
Free Online SharePoint Framework WebinarFree Online SharePoint Framework Webinar
Free Online SharePoint Framework Webinar
 
Using an in-house WordPress framework
Using an  in-house WordPress frameworkUsing an  in-house WordPress framework
Using an in-house WordPress framework
 

Similaire à Dog food conference creating modular webparts with require js in sharepoint

Introduction to using jQuery with SharePoint
Introduction to using jQuery with SharePointIntroduction to using jQuery with SharePoint
Introduction to using jQuery with SharePointRene Modery
 
web intership ritesh.pptx
web intership ritesh.pptxweb intership ritesh.pptx
web intership ritesh.pptxJenaj2
 
jQuery: The World's Most Popular JavaScript Library Comes to XPages
jQuery: The World's Most Popular JavaScript Library Comes to XPagesjQuery: The World's Most Popular JavaScript Library Comes to XPages
jQuery: The World's Most Popular JavaScript Library Comes to XPagesTeamstudio
 
Experiences using CouchDB inside Microsoft's Azure team
Experiences using CouchDB inside Microsoft's Azure teamExperiences using CouchDB inside Microsoft's Azure team
Experiences using CouchDB inside Microsoft's Azure teamBrian Benz
 
Red Hat JBoss BRMS and BPMS Workbench and Rich Client Technology
Red Hat JBoss BRMS and BPMS Workbench and Rich Client TechnologyRed Hat JBoss BRMS and BPMS Workbench and Rich Client Technology
Red Hat JBoss BRMS and BPMS Workbench and Rich Client TechnologyMark Proctor
 
Vijay Oscon
Vijay OsconVijay Oscon
Vijay Osconvijayrvr
 
Front End Development | Introduction
Front End Development | IntroductionFront End Development | Introduction
Front End Development | IntroductionJohnTaieb
 
Starting with jQuery
Starting with jQueryStarting with jQuery
Starting with jQueryAnil Kumar
 
web development 7.pptx
web development 7.pptxweb development 7.pptx
web development 7.pptxharshit762481
 
jQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesMark Roden
 
Mix Tech Ed Update No Video
Mix Tech Ed Update No VideoMix Tech Ed Update No Video
Mix Tech Ed Update No VideoAllyWick
 
Introduction To Code Igniter
Introduction To Code IgniterIntroduction To Code Igniter
Introduction To Code IgniterAmzad Hossain
 
Having fun with code igniter
Having fun with code igniterHaving fun with code igniter
Having fun with code igniterAhmad Arif
 
Normalizing x pages web development
Normalizing x pages web development Normalizing x pages web development
Normalizing x pages web development Shean McManus
 
Approaches to mobile site development
Approaches to mobile site developmentApproaches to mobile site development
Approaches to mobile site developmentErik Mitchell
 
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!Evan Mullins
 
Drupal 8 and iOS - an Open Source App
Drupal 8 and iOS - an Open Source AppDrupal 8 and iOS - an Open Source App
Drupal 8 and iOS - an Open Source ApplittleMAS
 
Best software development tools in 2021
Best software development tools in 2021Best software development tools in 2021
Best software development tools in 2021Samaritan InfoTech
 
Web Development with AngularJS, NodeJS and ExpressJS
Web Development with AngularJS, NodeJS and ExpressJSWeb Development with AngularJS, NodeJS and ExpressJS
Web Development with AngularJS, NodeJS and ExpressJSJoão Rocha da Silva
 
Building Applications With the MEAN Stack
Building Applications With the MEAN StackBuilding Applications With the MEAN Stack
Building Applications With the MEAN StackNir Noy
 

Similaire à Dog food conference creating modular webparts with require js in sharepoint (20)

Introduction to using jQuery with SharePoint
Introduction to using jQuery with SharePointIntroduction to using jQuery with SharePoint
Introduction to using jQuery with SharePoint
 
web intership ritesh.pptx
web intership ritesh.pptxweb intership ritesh.pptx
web intership ritesh.pptx
 
jQuery: The World's Most Popular JavaScript Library Comes to XPages
jQuery: The World's Most Popular JavaScript Library Comes to XPagesjQuery: The World's Most Popular JavaScript Library Comes to XPages
jQuery: The World's Most Popular JavaScript Library Comes to XPages
 
Experiences using CouchDB inside Microsoft's Azure team
Experiences using CouchDB inside Microsoft's Azure teamExperiences using CouchDB inside Microsoft's Azure team
Experiences using CouchDB inside Microsoft's Azure team
 
Red Hat JBoss BRMS and BPMS Workbench and Rich Client Technology
Red Hat JBoss BRMS and BPMS Workbench and Rich Client TechnologyRed Hat JBoss BRMS and BPMS Workbench and Rich Client Technology
Red Hat JBoss BRMS and BPMS Workbench and Rich Client Technology
 
Vijay Oscon
Vijay OsconVijay Oscon
Vijay Oscon
 
Front End Development | Introduction
Front End Development | IntroductionFront End Development | Introduction
Front End Development | Introduction
 
Starting with jQuery
Starting with jQueryStarting with jQuery
Starting with jQuery
 
web development 7.pptx
web development 7.pptxweb development 7.pptx
web development 7.pptx
 
jQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPagesjQuery - the world's most popular java script library comes to XPages
jQuery - the world's most popular java script library comes to XPages
 
Mix Tech Ed Update No Video
Mix Tech Ed Update No VideoMix Tech Ed Update No Video
Mix Tech Ed Update No Video
 
Introduction To Code Igniter
Introduction To Code IgniterIntroduction To Code Igniter
Introduction To Code Igniter
 
Having fun with code igniter
Having fun with code igniterHaving fun with code igniter
Having fun with code igniter
 
Normalizing x pages web development
Normalizing x pages web development Normalizing x pages web development
Normalizing x pages web development
 
Approaches to mobile site development
Approaches to mobile site developmentApproaches to mobile site development
Approaches to mobile site development
 
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
WordCamp Asheville 2017 - So You Wanna Dev? Join the Team!
 
Drupal 8 and iOS - an Open Source App
Drupal 8 and iOS - an Open Source AppDrupal 8 and iOS - an Open Source App
Drupal 8 and iOS - an Open Source App
 
Best software development tools in 2021
Best software development tools in 2021Best software development tools in 2021
Best software development tools in 2021
 
Web Development with AngularJS, NodeJS and ExpressJS
Web Development with AngularJS, NodeJS and ExpressJSWeb Development with AngularJS, NodeJS and ExpressJS
Web Development with AngularJS, NodeJS and ExpressJS
 
Building Applications With the MEAN Stack
Building Applications With the MEAN StackBuilding Applications With the MEAN Stack
Building Applications With the MEAN Stack
 

Dernier

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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 

Dernier (20)

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...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

Dog food conference creating modular webparts with require js in sharepoint

  • 1. Creating Modular WebParts with RequireJS in SharePoint Dog Food Conference Tuesday, September 30th, 2014 Christopher Fahey
  • 2. About Developer at Cardinal Solutions Group Doing SharePoint development for over 2 years Two Scrum certifications PSM, PSD Two Microsoft certifications 70-480, 70-486
  • 3. Logistics Use Hubb.me to schedule a one on one with me http://dogfoodcon.hubb.me Tweet at Dog Food https://twitter.com/hashtag/DogFoodCon #DogFoodCon @DogFoodCon Principles apply to various platforms/solutions Interactive presentation - ask questions during
  • 4. Goals Assuming everyone is a developer Beneficial and learn something as IT Pro, Manger, etc. Start building front-end solutions using RequireJS Encourage development of modular code
  • 6. Front end file and module loader AMD - Asynchronous Module Definition What are JavaScript modules? Encapsulate code into useful units and then expose its data and behavior Optimization tool
  • 8. Large project have many files in which managing the dependencies for each file becomes cumbersome Having to write many script tags is not scalable Easy to load scripts on demand References to other dependencies are done via global variables - often implicitly
  • 10. Pro Tip “ Implied global variables should never be used. Use of global variables should be minimized. Douglas Crockford ” http://javascript.crockford.com/code.html
  • 11. Why Start Using RequireJS Many popular libraries already work with RequireJS Decouples your applications Ease of maintenance
  • 12. Distinct functionality Small, single purpose scripts Single Responsibility (SOLID) Divide and conquer large applications into small blocks Helps manage dependencies Microsoft is pushing development towards front-end coded solutions in SharePoint
  • 13. Doing things the app way “ Custom code that runs on the SharePoint servers is not allowed in Apps for SharePoint. MSDN ” http://msdn.microsoft.com/en-us/library/office/jj163114(v=office.15).aspx
  • 15. RequireJS Basics ● Three global variables ○ window.define(); ○ window.require(); ○ window.requirejs; ● Assumes all scripts are in the /scripts directory ● The .js file extension is assumed ● Browser support back to IE6 and Firefox 2
  • 16. require() specify any dependencies runs like an immediate function require([“welcome”], function (welcome) { welcome.showTodaysDate(); welcome.greetUser(); });
  • 17. define() define() states we are creating module and using jQuery returns an object that exposes the desired data and behavior define([“jquery”], function ($) { var todaysDate = new Date(); return { today: todaysDate, showTodaysDate: function() { $(“.todays-date”).text(todaysDate); }, greetUser: function () { $(“.welcome”).text(“Hi”); } }; });
  • 18. configs() baseUrl is the root path for all module lookups paths is a mapping of urls for any module names shims helps manage dependencies of scripts many more configuration options require.config({ baseUrl: “/Style Library”, paths: { “jquery”: “jquery.1.7.1”, “u”: “underscore.1.7.0” }, shims: { “backbone”: { deps: [“jquery”, “u”] } } });
  • 20. Creating a WebPart Create a new SharePoint 2013 Project Deploy as Sandbox Solution Create a Visual WebPart Add Scripts leveraging RequireJS
  • 24.
  • 26. Lazy Loading Scripts (continued) Charts.js file was not downloaded until “Show All Data” button was clicked - about 20 seconds after page load
  • 27. Lessons Learned Very quick and easy to start using RequireJS, but unlikely current code base will “just work” Figure out a pattern and stick with it Naming Keep files small, do one thing at a time
  • 30. Resources http://requirejs.org http://addyosmani.com/writing-modular-js http://blog.teamtreehouse.com/organize-your-code- with-requirejs http://youtube.com/watch?v=eRqsZqLyYaU
  • 31. Discussion Slides http://www.slideshare.net/fahey252 Connect https://www.linkedin.com/in/christopherpatrickfahey Schedule a one on one http://dogfoodcon.hubb.me

Notes de l'éditeur

  1. 6 months and has changed the way I develop code Ridiculously easy with tons of benefits. Found it leads to better design and most important code reusability. Reminds me of when I used jQuery 1/3’s front-end developers/already using RequireJS?
  2. Happily employed at Cardinal Solutions Been on an awesome and large SharePoint project for over 2 years Developed 60 custom rapid solutions using front-end code Pursuing (MCSD) certification
  3. Sponsors, learn something or meet someone new, never know when they can help you Was at Sencha talk this morning and Sencha has a requires property – very similiar Not just me talking - throw a hand up in the air, speak out
  4. Deliver value JavaScript heavy and uses many powerful features of JavaScript Protips There are many options. Improve the speed and the quality of your code. will touch on lessons learned at the end once we go through examples.
  5. RequireJS is ridiculously easy.
  6. Optimized for browser use but can be used in other environments like Node. Lots of different patterns (front end) for JavaScript modules. Includes an optimization tool (r.js and UgligyJS) you can run as part of your packaging steps for deploying your code. The optimization tool can combine and minify your JavaScript files to allow for better performance. I will not be talking about the optimization part feature of RequireJS.
  7. Knowing dependencies and their order is generally assumed. Dependencies are assumed to be immediately available. Load small scripts in pieces instead of one large monolithic procedural file, especially in mobile senarious
  8. Dependencies, number, ordering
  9. pollution the global namespace. Question? Does anyone know what an implied global variable is?
  10. Encourages modular code - Increases reusability Single Responsibility - focus on code correctness and maintenancey Script loading - asynchronously/in parallel Microsoft has invested heavily in REST for front-end development/JSOM
  11. Microsoft pushing towards front end code in SP. More code, more dependencies, more problems. True for Office365 and SharePoint hosted apps
  12. require(): loads dependencies and run the code the trailing .js is assumed - assumes all files being loaded are JS files.
  13. define(): create reusables modules (Use) returns module the trailing .js is assumed - assumes all files being loaded are JS files. State fundamental difference between define() and require()
  14. Paths are kinda like shortcuts the trailing .js is assumed - assumes all files being loaded are JS files. configs: exports, packages, i18n, waitSeconds
  15. Any questions thus far? Showing a simple example of a project in Visual Studio using RequireJS
  16. RequireJS is the entry point for the application
  17. Make explicit that I clicked the Show All Data
  18. Notice initiator is RequireJS Especially important for a mobile app to only load resources as they are needed.
  19. In general, easy to make script AMD ready/work with RequireJS Wish would have started using sooner. Keither Mayer - “Steal what you can, build what you can’t” - on Automation with Powershell in Azure
  20. Wish would have started using sooner. In general, easy to make script AMD ready/work with RequireJS
  21. usese Jasmine for BDD testing. Develop and refactor code with confidence.
  22. Summary: Ridiculously easy to get started, huge payouts. Will change the the way you develop code. Questions: Who is ready to start Using RequireJS? Improvements: Add a before and after code about before RequireJS and after what it looks like.