Your SlideShare is downloading. ×
On SharePoint Development – JavaScript
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

On SharePoint Development – JavaScript

400
views

Published on

Presentation fom 7/12/2012 from the Critical Path Training 2012 webinar series.

Presentation fom 7/12/2012 from the Critical Path Training 2012 webinar series.

Published in: Technology

1 Comment
0 Likes
Statistics
Notes
  • Be the first to like this

No Downloads
Views
Total Views
400
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
1
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • As developers, our ONLY reasons for coding JavaScript are a better user experience or meeting some business requirement. In each case, JavaScript comes into play only when server side code can’t or won’t do what we need. Maybe we need to get better perceived performance by avoiding a postback; maybe we’re tweaking the UI in a way SharePoint doesn’t allow us to do or makes harder to do server side; maybe we’re sidestepping the restrictions of the sandbox.
  • A nit, but an important one. There’s a *huge* volume of JavaScript information out there – don’t ignore it! Sometimes a few lines of well crafted JavaScript can fill in for a few hundred lines of JQuery
  • Be careful with business logic – it REALLY doesn’t belong on the server
  • SOD works best with “utility” type libraries where dependencies might exist to other files
  • var: declare local variablesClosure: Function that provides access to private variables via a public objectModule:NameSpacing: avoid polluting the global object, avoid collisionsIIFE: Immediately Invoked Function Expression. Wrap everything in a function (object) and immediately run it. Only the top-level function is in the global namespaceThink a collision is unlikely? Just add your web part to a page twice…
  • Need to deploy your .js files and/or JavaScript libraries and make them available on the server
  • Demo: Show VS project and cksscript.codeplex.com
  • Potentially testing on 6+ browsers/operating systemsTest >1 web part on a page
  • CEWP – even as a temporary shortcut, don’t fall into that habit as it’s too hard to say “I’ll do that better later.” You never will…
  • Transcript

    • 1. On SharePoint Development – JavaScriptDavid MannAptillon
    • 2. David Mann Director/CoFounder - Aptillon • www.Aptillon.com • @MannD, @OnSPDev • MVP since 2007 • Author • Speaker • Community-guy
    • 3. On SharePoint Development On SharePoint Development Insights from a journeyman coder Episode 6: JavaScript David Mann
    • 4. About Me• David Mann• SharePoint since 2001-ish• SharePoint MVP since 2007• Developer, Architect, Author, Speaker, Trainer, Community-guy• SharePoint Padawan
    • 5. About Aptillon • SharePoint MVPs • Microsoft Certified Master • Consultants, Trainers, Authors, Speakers, Bloggers • Great People, Great Experience, Great Passion David Mann Gary Lapointe Darrin Bishop Maurice Prather Matthew McDermott
    • 6. What to Expect • Summary level – way too much to cover in detail • Detailed write-ups/demos/screencasts at www.onsharepointdevelopment.com • Started, more coming soon
    • 7. Why JavaScript? • Better User Experience • More responsive UI • Tweaking the UI • Meet Business Requirements • Some things SharePoint doesn’t let us do natively
    • 8. Why JavaScript and SharePoint? • SharePoint is an ASP.Net Application • SharePoint already making huge use of JavaScript
    • 9. JavaScript or JQuery? • JQuery is JavaScript • No such thing as “writing JQuery”. You use JQuery to simplify writing JavaScript • JQuery makes writing JavaScript easier/faster • May negatively impact runtime performance(unlikely, but possible) • Other JavaScript libraries available • http://javascriptlibraries.com/ • Each better/worse at some things
    • 10. What Can We Do? • (Just About) Any UI manipulation we want / need • Eye Candy • Actual business value • Server interaction (calls from the client) • CRUD - values, settings, etc. • Business logic?
    • 11. Efficiency & Performance • On the client, but… • Script Loaders • SOD Demo • Most expensive part? • Non-blocking scripts
    • 12. Script On Demand
    • 13. Error Handling • try/catch/finally • With a twist • Reduce roundtrips
    • 14. Error Handling
    • 15. Don’t go GLOBAL • Avoid polluting the global namespace • var is your friend Demo • Closures • Module pattern • Namespacing • IIFE • Bringing it all together… Demo
    • 16. Don’t Go Global…
    • 17. Deployment• _layouts • Not sandbox-compatible • Best performance • Harder to maintain • Need server-access • No meta/functionality (metadata, versioning, etc)• Site Pages (ghosted) • Same performance as _layouts • Sandbox-compatible, but lose performance benefits • Hardest to maintain (requires SPD)
    • 18. Deployment• Script Library • Easiest to maintain (browser) • Sandbox compatible • SOD compatible • Highest degree of meta/functionality • Minor performance hit • CKS:ScriptLibrary • Common libraries (JQuery, etc) • Utilities (more coming) Demo • Features for debugging • CKSScript.Codeplex.com
    • 19. CKS Script Library
    • 20. Activation • ScriptLink control • Not Sandbox compatible • MasterPage / <script> tag • Hard to maintain • Blocking • Custom Action • Best option • Controllable via Features
    • 21. Testing Supported with Browser Supported Not supported limitations Internet Explorer 32-bit 64-bit 9 Internet Explorer 32-bit 64-bit 8 Internet Explorer 32-bit 64-bit 7 Google Chrome (latest publically X released version) Mozilla Firefox (latest publically X released version) Apple Safari (latest publically X released version) From: http://technet.microsoft.com/en-us/library/cc263526.aspx
    • 22. Defensive Coding • Confirm before using
    • 23. Source Control • CEWP is evil. Don’t use it. • .js files • Versioned • Secured • Backed up • Snapshot • Reusable • Manageable
    • 24. Resources • Posted this weekend (7/15/12): • www.onsharepointdevelopment.com • CKSScriptLibrary.CodePlex.com
    • 25. Thanks! • dave@aptillon.com • @OnSPDev • (no tweets yet  ) • www.OnSharePointDevelopment.com • Slowly building out content…I’m a little behind…