SPSTC: Mark Rackley on ‘SharePoint & jQuery – What I Wish I Would Have Known When I Started’

Mark Rackley presents on jQuery and SharePoint at SPSTCDCMark Rackley, aka the "SharePoint Hillbilly," presented his SPSTC session on SharePoint and jQuery to the very definition of a packed house today.  In truth, as a non-developer, this fact caused me to feel a little guilty for taking up a seat but, with luck, my coverage of Mark's session will prove me at least somewhat worthy. 

Mark began by candidly acknowledging, "I know there are some haters out there… because [jQuery] does suck," before completing the statement with, "…and it is awesome."  Mark then defined jQuery as being "just a JavaScript utility library that allows you to quickly write interactive and usable applications."  Mark named as prerequisites and necessary skills for its use:  JavaScript, CSS, XML, CAML, a development background, and an ability to think outside the box. 

Mark said that "jQuery makes your SharePoint apps usable," and that jQuery myths include: jQuery isn't secure ("It's just as secure as you set up your system"); jQuery doesn't perform well ("It does if you use it right"); and You can't elevate privileges (Actually, this is true and, per Mark, that's a good thing).

Regarding deployment options, Mark's recommendation is to "create a central scripts library."  He then showed his own jQuery library, pointing out the detailed comments which specified which files were using a given script.  Note: Mark cautioned that there is a "slight performance hit" since the scripts are stored in the content library.

Regarding maintenance, Mark called out as a bad practice that you "Do not put your scripts directly in the MasterPage," because "it makes things totally unmanageable … don't do it."  Also don't put your script source in the Content Editor Web Part.  Mark mentioned at this point that he's just started a blog series on A Dummies Guide to SharePoint and jQuery, so check that out at your leisure.  A better practice ("best in some cases") Mark shared is to "link to scripts in a Content Editor Web Part."  A best practice ("maybe in some cases") is to employ a "Custom Control linked to script, deployed as a solution."

Addressing the topic of moving between environments (and upgrading t 2010), Mark said of jQuery, "It just works."  Among the potential gotchas to be aware of with jQuery, however, Mark mentioned that "jQuery does expose your business logic to the user," and that it's "much harder to give people a consistent experience using jQuery."  Mark also discussed things you can't do with jQuery, which include:

  • Timer jobs
  • Workflows
  • Event handlers
  • Elevate privileges
  • Easily interact with all business systems

Mark then went into a variety of development basics and, as they included no small amount of code, this is as good a time as any for me to suggest that you avail yourself of the fact that Mark has generously made his slide deck available for viewing and/or downloading at SlideShare.

Mark then discussed SPServices, saying that it's "a jQuery library" that allows you to execute SharePoint's Web Services.  Mark went on to say, "It's a good library, I recommend it," noting that it does have a number of quirks about which you should be aware (see the "SPServices FYI" slide in Mark's deck for full details), before providing an example of an SPService call. 

Among Mark's development tips, he advised that you "develop for performance … delay your loads until you need them, [for] a big boost in performance," and utilize IDs and attributes to your advantage. 

As far as where to write jQuery, Mark said, "Pick whatever editor makes you happy," naming as options: SharePoint Designer, Visual Studio, Aptana, and Notepad++ (the last of which received props because it "has bracket matching").

Addressing the topic of debugging jQuery, Mark flatly stated, "It sucks," but advised that alerts are key, and that there are available dev tools to help with your debugging efforts.  Dev tools, and a raft of common debugging errors that Mark shared are available for your perusal in Mark's slide deck.

Mark wrapped up his session with a series of screenshots and demos of jQuery apps he's developed for the U.S. Department of State, but you won't find those in his slide deck, so if you get a chance to catch his presentation (such as at the upcoming SharePoint Conference in Anaheim), don't miss it!

 

Read our complete coverage of SharePoint Saturday: The Conference: