SlideShare a Scribd company logo
1 of 31
Download to read offline
You don’t know JS about
SharePoint – SharePoint
JavaScript Context best
practices for C# developers
Hugh Wood
 Hugh Wood
 Rencore AB
 www.SPCAF.com
 Hugh.Wood@Rencore.se
 Professional software developer since 2000, first
wrote JS in `95, first wrote code in `87.
Expert in compiler theory, code security and
code performance.
Agenda
 Introduction to the topic
 JS File Structure
 Garbage Collection
 Dynamic Module Loading
 Built in Helper Methods
Introduction
Why you should care
Source: Loggly
C# JavaScript
Multi-Paradigm Functional, Event Driven
Strongly Typed OR
Loosely Typed
Loosely Typed (Strong
types are coming 2015)
ECMA-334 ECMAScript-5
Inside SharePoint
JavaScript File Structure
 The Module Pattern
 It must provide public facing methods
 A module must have an initialiser method
 A module must have a finaliser method
 Supporting members may require additional
initialisation/finalisation code
 Members are used to perform operations on
elements external to the class
JS FILE STRUCTURE
ADM
 Asynchronous Download Manager
 The technology behind MDS (Minimal
Download Strategy)
 It simulates full page load
 Only loads parts of the page
 Re-initialises the bootstrap
ADM Program Flow
ADM – What we need to do
 Register our namespace
 Register the initialisation method
Dynamic Module Loading
 Lazy loading external files
 Same principle as a DLL
 Asynchronous Module Definition
 Not available in ECMA5
 It will be available in ECMA6
 SharePoint won’t be using ECMA6
Dynamic Module Loading
 Scripts On Demand (SP.SOD)
 Each script must:
– Use a named method around the code
– Register this method with SharePoint
– Report it is ready when loaded
– Register a module initialisation method if required
Dynamic Module Loading
 Scripts On Demand (SP.SOD)
 To load each script we must:
– Register the script with SharePoint
– Ask the script to be loaded
– Give an action to be executed when the script has
been loaded
Scripts On Demand
 Available Methods for Scripts
 Register SOD
 Register SOD Dependency
 Load by Key / Load Multiple
 Execute or Delay until Script Loaded
 Execute / Execute Function
 Notify Script Loaded
SCRIPTS ON DEMAND
A FULL MODULE
Where do we put our core
module?
 Core Module – Not on demand via
CustomAction
 Other parts – On demand as needed
 ScriptLink
 JS Link
 Another JS file
 NEVER from a Script Block
But what can we gain?
 SP.Init – Learn this file.
 Built in helper methods
 SP.ScriptUtility
 SP.ScriptHelpers
 mQuery
 SP.Utilities
– Task Engine
– Animation
Cancellable Command API
Working on it…
This shouldn’t take long.
#SPSSTHLM19: SharePoint JavaScript, doing it right – @HughAJWood
#SPSSTHLM19: SharePoint JavaScript, doing it right – @HughAJWood
Animation Engine
#SPSSTHLM19: SharePoint JavaScript, doing it right – @HughAJWood
#SPSSTHLM19: SharePoint JavaScript, doing it right – @HughAJWood
Remote Request Executor
#SPSSTHLM19: SharePoint JavaScript, doing it right – @HughAJWood
#SPSSTHLM19: SharePoint JavaScript, doing it right – @HughAJWood
mQuery
m$
#SPSSTHLM19: SharePoint JavaScript, doing it right – @HughAJWood
GOTCHAS
 Private properties are extra private across
files - Handled
 Race conditions - Practice
 SharePoint probably already has a method
for that – Learn
 No documentation - Governance
Governance
Pro Con
Tested and Guaranteed Patches can change
code
Reduced development
time
Could contain a bug
Less overhead on client No documentation
Easier to maintain code Overly Complex for
simple tasks
Wrapping it up




Ask me anything and
tell me what you want to hear
about.
Hugh Wood
www.spcaf.com/blog
@hughajwood

More Related Content

What's hot

What's hot (20)

10 reasons to migrate from AEM 5 to 6.1
10 reasons to migrate from AEM 5 to 6.110 reasons to migrate from AEM 5 to 6.1
10 reasons to migrate from AEM 5 to 6.1
 
Building Faster With Your Team's UI Kit
Building Faster With Your Team's UI KitBuilding Faster With Your Team's UI Kit
Building Faster With Your Team's UI Kit
 
An iOS Developer's Perspective on React Native
An iOS Developer's Perspective on React NativeAn iOS Developer's Perspective on React Native
An iOS Developer's Perspective on React Native
 
A quick introduction to GraphQL
A quick introduction to GraphQLA quick introduction to GraphQL
A quick introduction to GraphQL
 
QAAgility Presentation - Cucumber with Appium
QAAgility Presentation - Cucumber with AppiumQAAgility Presentation - Cucumber with Appium
QAAgility Presentation - Cucumber with Appium
 
React native-meetup-talk
React native-meetup-talkReact native-meetup-talk
React native-meetup-talk
 
Getting Started With Cypress
Getting Started With CypressGetting Started With Cypress
Getting Started With Cypress
 
Blazor and Azure Functions - a serverless approach
Blazor and Azure Functions - a serverless approachBlazor and Azure Functions - a serverless approach
Blazor and Azure Functions - a serverless approach
 
Streamlining API with Swagger.io
Streamlining API with Swagger.ioStreamlining API with Swagger.io
Streamlining API with Swagger.io
 
Design Driven API Development
Design Driven API DevelopmentDesign Driven API Development
Design Driven API Development
 
Putting the Native in React Native - React Native Boston
Putting the Native in React Native - React Native BostonPutting the Native in React Native - React Native Boston
Putting the Native in React Native - React Native Boston
 
SpringPeople Introduction to iOS Apps Development
SpringPeople Introduction to iOS Apps DevelopmentSpringPeople Introduction to iOS Apps Development
SpringPeople Introduction to iOS Apps Development
 
API Developer Experience: Why it Matters, and How Documenting Your API with S...
API Developer Experience: Why it Matters, and How Documenting Your API with S...API Developer Experience: Why it Matters, and How Documenting Your API with S...
API Developer Experience: Why it Matters, and How Documenting Your API with S...
 
GitHub as a Landing Page
GitHub as a Landing Page GitHub as a Landing Page
GitHub as a Landing Page
 
Why your APIs should fly first class
Why your APIs should fly first classWhy your APIs should fly first class
Why your APIs should fly first class
 
Managing Omnichannel Experiences with Adobe Experience Manager (AEM)
Managing Omnichannel Experiences with Adobe Experience Manager (AEM)Managing Omnichannel Experiences with Adobe Experience Manager (AEM)
Managing Omnichannel Experiences with Adobe Experience Manager (AEM)
 
Developing Faster with Swagger
Developing Faster with SwaggerDeveloping Faster with Swagger
Developing Faster with Swagger
 
PHP framework difference
PHP framework differencePHP framework difference
PHP framework difference
 
Intro to Service Worker API and its use cases
Intro to Service Worker API and its use casesIntro to Service Worker API and its use cases
Intro to Service Worker API and its use cases
 
Introduction to React Native
Introduction to React NativeIntroduction to React Native
Introduction to React Native
 

Similar to You don’t know js about share point – hugh wood

In Act Developers Platform
In Act Developers PlatformIn Act Developers Platform
In Act Developers Platform
Eris Ristemena
 
Content-centric architectures - case study : Apache Sling
Content-centric architectures - case study : Apache SlingContent-centric architectures - case study : Apache Sling
Content-centric architectures - case study : Apache Sling
Fabrice Hong
 
Application depolyment
Application depolymentApplication depolyment
Application depolyment
shriikantL
 

Similar to You don’t know js about share point – hugh wood (20)

AEM Best Practices for Component Development
AEM Best Practices for Component DevelopmentAEM Best Practices for Component Development
AEM Best Practices for Component Development
 
WP REST API - Building a simple Web Application
WP REST API - Building a simple Web ApplicationWP REST API - Building a simple Web Application
WP REST API - Building a simple Web Application
 
Professionalizing the Front-end
Professionalizing the Front-endProfessionalizing the Front-end
Professionalizing the Front-end
 
Intro to SpringBatch NoSQL 2021
Intro to SpringBatch NoSQL 2021Intro to SpringBatch NoSQL 2021
Intro to SpringBatch NoSQL 2021
 
Web Development in Django
Web Development in DjangoWeb Development in Django
Web Development in Django
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
 
Broadcast Music Inc - Release Automation Rockstars!
Broadcast Music Inc - Release Automation Rockstars!Broadcast Music Inc - Release Automation Rockstars!
Broadcast Music Inc - Release Automation Rockstars!
 
Sst hackathon express
Sst hackathon expressSst hackathon express
Sst hackathon express
 
In Act Developers Platform
In Act Developers PlatformIn Act Developers Platform
In Act Developers Platform
 
Booting up with polymer
Booting up with polymerBooting up with polymer
Booting up with polymer
 
Pain Driven Development by Alexandr Sugak
Pain Driven Development by Alexandr SugakPain Driven Development by Alexandr Sugak
Pain Driven Development by Alexandr Sugak
 
Content-centric architectures - case study : Apache Sling
Content-centric architectures - case study : Apache SlingContent-centric architectures - case study : Apache Sling
Content-centric architectures - case study : Apache Sling
 
Spring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applicationsSpring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applications
 
Building and managing applications fast for IBM i
Building and managing applications fast for IBM iBuilding and managing applications fast for IBM i
Building and managing applications fast for IBM i
 
Spring Boot & Actuators
Spring Boot & ActuatorsSpring Boot & Actuators
Spring Boot & Actuators
 
SharePoint Framework -The future of SharePoint/ Office 365 developer ecosystem.
SharePoint Framework -The future of SharePoint/ Office 365 developer ecosystem. SharePoint Framework -The future of SharePoint/ Office 365 developer ecosystem.
SharePoint Framework -The future of SharePoint/ Office 365 developer ecosystem.
 
Tutorial 1: Your First Science App - Araport Developer Workshop
Tutorial 1: Your First Science App - Araport Developer WorkshopTutorial 1: Your First Science App - Araport Developer Workshop
Tutorial 1: Your First Science App - Araport Developer Workshop
 
Drupal
DrupalDrupal
Drupal
 
Application depolyment
Application depolymentApplication depolyment
Application depolyment
 
Spring boot
Spring bootSpring boot
Spring boot
 

Recently uploaded

Recently uploaded (20)

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
 
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
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
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...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
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
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
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...
 
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...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

You don’t know js about share point – hugh wood

  • 1. You don’t know JS about SharePoint – SharePoint JavaScript Context best practices for C# developers Hugh Wood
  • 2.  Hugh Wood  Rencore AB  www.SPCAF.com  Hugh.Wood@Rencore.se  Professional software developer since 2000, first wrote JS in `95, first wrote code in `87. Expert in compiler theory, code security and code performance.
  • 3. Agenda  Introduction to the topic  JS File Structure  Garbage Collection  Dynamic Module Loading  Built in Helper Methods
  • 5. Why you should care Source: Loggly
  • 6. C# JavaScript Multi-Paradigm Functional, Event Driven Strongly Typed OR Loosely Typed Loosely Typed (Strong types are coming 2015) ECMA-334 ECMAScript-5
  • 7.
  • 9. JavaScript File Structure  The Module Pattern  It must provide public facing methods  A module must have an initialiser method  A module must have a finaliser method  Supporting members may require additional initialisation/finalisation code  Members are used to perform operations on elements external to the class
  • 11. ADM  Asynchronous Download Manager  The technology behind MDS (Minimal Download Strategy)  It simulates full page load  Only loads parts of the page  Re-initialises the bootstrap
  • 13. ADM – What we need to do  Register our namespace  Register the initialisation method
  • 14. Dynamic Module Loading  Lazy loading external files  Same principle as a DLL  Asynchronous Module Definition  Not available in ECMA5  It will be available in ECMA6  SharePoint won’t be using ECMA6
  • 15. Dynamic Module Loading  Scripts On Demand (SP.SOD)  Each script must: – Use a named method around the code – Register this method with SharePoint – Report it is ready when loaded – Register a module initialisation method if required
  • 16. Dynamic Module Loading  Scripts On Demand (SP.SOD)  To load each script we must: – Register the script with SharePoint – Ask the script to be loaded – Give an action to be executed when the script has been loaded
  • 17. Scripts On Demand  Available Methods for Scripts  Register SOD  Register SOD Dependency  Load by Key / Load Multiple  Execute or Delay until Script Loaded  Execute / Execute Function  Notify Script Loaded
  • 18. SCRIPTS ON DEMAND A FULL MODULE
  • 19. Where do we put our core module?  Core Module – Not on demand via CustomAction  Other parts – On demand as needed  ScriptLink  JS Link  Another JS file  NEVER from a Script Block
  • 20. But what can we gain?  SP.Init – Learn this file.  Built in helper methods  SP.ScriptUtility  SP.ScriptHelpers  mQuery  SP.Utilities – Task Engine – Animation
  • 21. Cancellable Command API Working on it… This shouldn’t take long. #SPSSTHLM19: SharePoint JavaScript, doing it right – @HughAJWood
  • 22. #SPSSTHLM19: SharePoint JavaScript, doing it right – @HughAJWood
  • 23. Animation Engine #SPSSTHLM19: SharePoint JavaScript, doing it right – @HughAJWood
  • 24. #SPSSTHLM19: SharePoint JavaScript, doing it right – @HughAJWood
  • 25. Remote Request Executor #SPSSTHLM19: SharePoint JavaScript, doing it right – @HughAJWood
  • 26. #SPSSTHLM19: SharePoint JavaScript, doing it right – @HughAJWood
  • 27. mQuery m$ #SPSSTHLM19: SharePoint JavaScript, doing it right – @HughAJWood
  • 28. GOTCHAS  Private properties are extra private across files - Handled  Race conditions - Practice  SharePoint probably already has a method for that – Learn  No documentation - Governance
  • 29. Governance Pro Con Tested and Guaranteed Patches can change code Reduced development time Could contain a bug Less overhead on client No documentation Easier to maintain code Overly Complex for simple tasks
  • 31. Ask me anything and tell me what you want to hear about. Hugh Wood www.spcaf.com/blog @hughajwood