jump to navigation

Best way to speed up Javascript (specifically jQuery) load times November 12, 2012

Posted by willhlaw in Javascript, jQuery, Web 2.0.
Tags: , , ,
1 comment so far


The obvious way is to use a popular CDN, short for Content Delivery Network, such as Google’s. Dave Ward explains the reasons very well in his article, “3 reasons why you should let Google host jQuery for you” and his three main points are:

  1. Decreased Latency – CDN allows the download to occur from the closest server to the user.
  2. Increased Parallelism – The local web server can be serving up content while the other connection is pulling from Google.
  3. Better Caching – Since so many other sites are using Google’s CDN, the user may already have the jQuery or javascript file in their cache.

However, there is a caveat. What if the connection to Google goes down? Can your site survive without jQuery? It should, if you developed the site with a responsive design and progressive enhancement.

The answer is to fall back to a local copy (code sample below).

  1. Write a script tag that refers to Google’s CDN.
  2. Then in the next script fragment, check to see if the jQuery or some public variable from the javascript file exists.
  3. If the object does not exist, then dynamically write another script to the page that refers to the local file.
<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if necessary -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.5.1.min.js">\x3C/script>')</script>

I learned this concise technique while watching a Twitter Bootstrap 101 tutorial (kudos to David Cochran for the great videos) that referred to this best practice that appears to have come from the HTML5 Boiler Plate project.

By the way, the numbers (from Pingdom) support Google as being most likely the best CDN to use.

CDN performance numbers

I will be speaking on SharePoint Saturday to promote and support TWO good causes November 19, 2009

Posted by willhlaw in Gov 2.0, jPoint, sharejPoint, SharePoint, SPSDC, Web 2.0.
Tags: , , , , , ,

[Update] – Schedule of presentations has been posted.  My session is from 8:30 – 9:30am and bio page is here.

On Dec. 5, the SharePoint Saturday for DC (#SPSDC) event will be hosted at the Microsoft Technology Center.  The call for speakers were for non SharePoint 2010 content and specifically, for solutions that addressed relevant business needs for the Washington, DC area.  In other words (more or less), this means “Who wants to talk about solutions useful for the Government?”  I was interested and could have repeated one of my previous SharePoint presentations about reporting airplane incident/accident events within SharePoint or about categorizing your data to plan for various degrees of high availability in SharePoint.  Both are certainly relevant to the government.  However, after Dux Raymond Sy checked out the jPoint project, he encouraged me to submit a speaker form to discuss it.  It is not directly related to the government, per se, but it will allow both the public and private sectors to improve the effectiveness of their SharePoint deployments.  Here is the list of speakers (I am at the bottom).

Thus, I made the title of my presentation “jPoint: A jQuery Based Library for creating Web 2.0 Apps in SharePoint”.  I have the description of the talk at the bottom of this post.  At the presentation, I hope that some of the jPoint contributors, like Ken, Samir, and Luke, will be present so you can meet some of the incredible talent that is helping to create a client side API in JavaScript for SharePoint and jump starting the effort to build solutions on top of the API – see the neat examples at http://sharejPoint.com/examples. Now on to promoting the good causes.

salvationArmyGood Cause #1

SharePoint Saturday will be promoting a Clothing Drive.  Warm clothes will be especially helpful for the needy in the coming Winter months.  I love when hard work can be directed towards a good cause, such as national safety, the disadvantaged, and of course, charity. Below is an excerpt from http://www.sharepointsaturday.org/dc/default.aspx.

#SPSDC Clothing Drive

Thursday, October 29, 2009

If you are planning to attend SharePoint Saturday DC on December 5, 2009, make sure you bring clothing that are new or in good condition to be donated to local charities like Salvation Army.

Clothing-donation needs include: school clothes, coats and other cold-weather accessories, professional clothing for employment interviews, and shoes, which wear out quickly and must be replaced often, especially among growing children.

Clothing donations to qualified charitable organizations are tax deductible.
For tax deduction purposes, The Salvation Army publish guidelines for the valuation of donated items, including clothing and shoes.

Let’s show the true meaning of connecting and collaborating. As Karuana Gatimu (one of the great SharePoint community leaders today) says “Sharing is the Point!”

Good Cause #2

The second good cause I will be promoting is jPoint.  Why?  It is simple.  It is free and saves time.  It is arguably not as important as the clothing drive, in the short term.  But bear with me.  I have a long term vision in mind.  jPoint is a free, open source project that will make developers lives easier and give SharePoint site administrators the ability to deploy customizations and “Web 2.0” mashups or composite applications without having to write code or touch the server.  I want to do my part in the community to create and spread the adoption of cost saving, valued added tools that increase the end user experience.  Increasing the end user experience will increase adoption and that will not only set the stage for increasing user productivity, but should also increase the efficiency of business processes and make everyone better off.  What do you think?  Checkout my talk at SharePoint Saturday or get involved with the project at http://jPoint.codeplex.com.  And similar to Kauruana’s quote above, jPoint’s motto is: “Share jPoint. It’s open source.”


Description of the SharePoint Saturday presentation – “jPoint: A jQuery Based Library for creating Web 2.0 Apps in SharePoint

Have you ever wanted to hide certain fields in a SharePoint list form that were “For Office Use Only?” Or to create a chat/IM tool or AJAX enable a list, but did not have rights to deploy a custom solution on the server? Or to use drag and drop functionality on a SharePoint page? Many developers have turned to jQuery client-side scripts to solve these issues. Many solutions take to much time to get off the ground and they break when used in other browsers. And what about your current client-side scripts when you upgrade to SharePoint 2010? Will they work? These problems are being solved by the FREE open source community project called jPoint. It is hosted on codeplex at http://jPoint.codeplex.com. jPoint is a data access layer for SharePoint to make it easier for developers to work with form fields and communicate with the SharePoint web services. It also provides a deployment framework so developers can create jPart “plugins” that site Administrators can drop on their pages to create Web 2.0 mashups.

This presentation will comprise of three segments:

1: Demo of a real life Web 2.0 App in SharePoint

2: Explanation of jParts and how Site Admins can configure them

3: Deep dive into jPoint library and API  (time permitting)

This session level is ranked intermediate and for Special Interest.  Leave me a comment if you are interested in the demo videos or any post-presentation material.  Thanks.