10 ways we made SlideShare faster

by Apoorvi Kapoor on October 18, 2013

in HTML5,JavaScript,Performance

At SlideShare, we love metrics. Be it weekly traffic data, number of uploads,number of pro sign ups or page load time ;we track each number very closely and strive to improve the numbers everyday. For Second Quarter of 2013, SlideShare’s CTO Jonathan Boutelle came up with the target of reducing our page load time to 5 seconds, which was hovering at an average of 7.5 seconds at that time.

This was not an easy task. We were already following web practices listed at Yslow. We had made every extra effort to achieve good grades at webpagetest. When it comes to page load time every millisecond reduction counts. Read on to find out how we got close to our target.

1. Load all third party libraries after window.load - To start with, all the javascript required for social sharing widgets eg Facebook like button should be loaded asynchronously.As a second step, move the script tags from the html page to a JavaScript(JS) file and bind the asynchronous loading of the external JS libraries to window.loadevent. For example, to load FB Like Button, place the following code in the JS file included in the head
$(window).load(function(){
(function(d){
var js, id = 'facebook-jssdk',
ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
}

And this is how our new relic graph looked like after we made this change.

ThirdPartWidgets

2. Asynchronously Load Jquery - Another useful trick is to load jQuery asynchronously so that other components on the page are not blocked.We used jql plugin which can be inlined in the HTML page.You don’t have to worry about missing document.ready( ) calls since jQl automatically catches all jQuery().ready() calls and executes them as soon as jQuery is loaded and the DOM is ready.

3. Combine and Compress - Combining the JS files help in eliminating the initial DNS lookup and TCP connection components that goes in every request. This is very evident from Yslow requests but an interesting tweak to this will be conditional compiling.For example let’s say your page requires jquery, file1.js, logged_in.js, logged_out.js.

Conditional compiling should give you combined_logged_in.js[jquery+file1.js+logged_in.js] and combined_logged_out.js[jquery+file1.js+logged_out.js]

For compressing JS , closure compiler is known to give the best results.

4. Smarter JS packaging - SlideShare has different functionality for logged in and logged out users. We load only base files for logged out users and additional JS files when the user logs in.Similarly the HTML5 player loads different type of combined JS files depending on the content type say presentations or documents.There is also a possibility that some plugins that you added initially are not being used anymore. Removing them is the first step towards minimizing size of assets that block page load.

5. Defer loading of JS - The main component of SlideShare which is the HTML5 player needs to be loaded as fast as possible. For this we are dependent on document.ready event. Therefore,the JS that is required for above the fold functionality is minimal and is loaded quite early.The other JS that is required for additional user functionality is loaded after window.load.

6. Lazy Load HTML and JS - This is a commonly used technique to show user generated content on page like comments etc only when the user interacts.We removed the inline html required for user actions like embed code and retrieved it on user click. This reduces the page size that the browser needs to parse and speeds up the load time.

7. Use of Cache Busters - All the assets like images, sprites, javascript files should have a cachebuster appended at the end of the URL so that the browser can cache the assets and makes a new request only if cache buster has changed.

8. Remove HTTPS calls from an http page- This can help you chop off a few milliseconds spent in SSL negotiation.

9. DNS prefetching - SlideShare uses multiple cdns to fetch various assets. We figured out that we can reduce DNS look up time by preresolving DNS in the browser.

10. Redesigning HTML5 player - Apart from these we also made certain improvements in our HTML5 player.The core of the SlideShare – HTML5 player is written in JavaScript using jQuery.The HTML5 player is a complex system which supports displaying presentations,documents , slidecasts and now Infographics too! To make a dent in the page load time by a good margin, we realized that we need to redesign the HTML5 player

  • We started with the idea that the player should be able to display content even if JavaScript is disabled in the browser and JS should only be used to make the player alive.

  • All the markup was generated on the client side using javascript which led to a lot of DOM manipulation. This was resolved by moving markup creation logic to backend.

  • The layout of slides and other styling logic was rewritten so that CSS rules can be used effectively instead of relying on JS

  • To make the user experience delightful, we included the first slide in the markup itself so that it is triggered by the browser parser instead of waiting on JS.

  • So what was the result of the above experiments? Our new relic graphs tell the entire story. A whooping drop from 5.7 to 5.03 seconds!

Before

newrelic1

After

last 3 hours

We used webpagetst extensively to measure the performance of the changes we were making. Here is how we have moved the needle for document complete event.

Before

webpagetest1

After

webpagetest3

None of the above would have been possible without the help of Jean Benois and Jeba Emmanuel.

If you find these tips useful or have any more ideas to make SlideShare faster ,please give a shout out in the comments below.So, what did you do to make your website faster?

Thanks

Apoorvi Kapoor

{ Comments on this entry are closed }

Brilliant Hacks at SlideShare Hackday 2013

by Prashant Verma on October 18, 2013

in Announcement,Hackdays,Hacks

Folks,

The 2013 SlideShare Hackday was organized on 3rd and 4th October. It was 30 hours of pure hackery and fun. Brilliant hacks, great participation and good food made this the best SlideShare hackday ever! We managed to capture some of the moments here for you:-

What cooked? Over 28 teams registered themselves and 25 of them successfully completed the hack prototypes. There were many brilliant hacks such as: -

  1. Minority report ARDrone Quadcopter with Leapmotion Control that flies and hounds the developer who breaks the build by Jeba Singh Emmanuel
  2. HTML5 Presentations – Upload native HTML5 presentations to SlideShare (yay!) by Neha, Akshit, Nikhil
  3. Picturesque – Quickly create a SlideShare photodeck from your Facebook photo album by Hitesh, Apoorvi, Himanshu
  4. Pseudo upload – Upload to SlideShare directly from your Gmail attachments by Jasmeet, Nitish, Gaurav
  5. Slideshare for Weddings – Quickly create a visual wedding card and upload to SlideShare by Jai, Shishir, Vishu
  6. #Comment – Capture discussions on a deck from Twitter and bring it to SlideShare as comments on the deck by Pranav, Tushar, Arpit
  7. Let’s create content – Content creation platform on slideshare by Arpit D, Dheeraj, Saptarshi
  8. Speaking Decks – Listen to the slide transcripts Troy, Arun, Bubby
  9. Conversion dev setup on vagrant by Chris
  10. SlideCaster – Slidecast and Zipcast at the same time by CaseyA, Omar, Mark
  11. Recommend content based on historic user-slideshow interaction by Kunal Mittal, Karan Jindal, Anupam Jain, Hari
  12. SoS – Chrome Widget for creating Content by Anil, Atul, Prashant
  13. Mobile reader by Andri, Jesse, Ben Silver, Ellis
  14. Slideshow as Video on facebook by Nishant, Jack
  15. SlideShare Collections by Varun , Vivek
  16. Content Organizer by Archana, Deepti, Moumita
  17. Photodeck – turn your album into slidedeck by Amit Banerjee
  18. Improved Transcript by Akash
  19. Infographic résumé by Simla Ceyhan, Sylvain Kalache, Yifu Diao
  20. Share with a click – share open positions on SS careers page to LI/Facebook by Priyanka R
  21. Rietveld on CentOS by Toby
  22. Think Mobile – Preview how your SlideShare deck appears on mobile devices by Ajay
  23. Convert blogs into SS decks by Subhendra Basu & Rashi

Who won? Each hack explored a different idea from a unique perspective. The most well-executed idea won. Here are the results –

Delhi Office:
1st Prize: Slideshare for Weddings by Jai, Shishir, Vishu
2nd Prize. HTML5 Presentation Support by Akshit, Neha, Nikhil

SF Office:
1st Prize: SlideCaster by Casey A, Omar & Mark.
2nd Prize: Infographic résumé by Simla, Sylvain & Yifu

Worthy mentions

  • Let’s create content (Arpit D, Dheeraj, Saptarshi)
  • Think Mobile (Ajay)
  • #Comment (Arpit B, Pranav, Tushar)

  • Does this sound exciting to you? If yes, then you’re like us. Why not consider applying for a job at SlideShare and become a part of this fun?

    { Comments on this entry are closed }

    Fluentd at Slideshare

    by Sylvain Kalache on June 28, 2013

    in Uncategorized

    SlideShare will be hosting the next Fluentd meetup July 8th at our San Francisco office.

    Fluentd is an open-source program that we have been using for the past year and a half that helps us with log management, carrying them from point A to point B in a fast and reliable way.

    Among a lot of good things about Fluentd, here are the three we like the most:

    • Everything that goes in and out of Fluentd is JSON.
    • Fluentd is written in about 2,000 lines of open source Ruby code. When you have an issue, you can just read/patch the code.
    • There is already a huge plugins library — about 150 — that allows you to import, filter and export your data into a variety of systems.

    If you want to know more about how we are using Fluentd, please have a look at one of our projects in which we are using it, and join us on July 8th!

    { Comments on this entry are closed }

    What’s Cooking in Our Labs: SlideShare HandsFree!

    by kapil on March 20, 2013

    in Announcement,Hackdays,Hacks,User Experience

    [Reposted from http://blog.slideshare.net/2013/03/19/whats-cooking-in-our-labs-slideshare-handsfree/]

    Clicking through presentations can be cumbersome, especially when you’re talking through them with a live audience at hand. You have to find the right key on your keyboard, or move your mouse to the correct button, often halting the flow of your speech. What if you could just flick your finger in the air, indicating movement to the next page?

    Our engineers are on it. We figured if you could play motion-sensing tennis on the Nintendo Wii, couldn’t you at least flip thought SlideShare presentations with the wave of a hand? Here’s a preview of what we’re working on:

    And here’s what the engineer himself, Shirsendu Karmakar, had to say about developing it (yes, he’s pretty cool!):
    If you have used/seen flutter, you wish you could use it on websites too. A few days back, I saw an interesting Chrome Experiment. My initial reaction: SlideShare “Minority Report” style! I started working on something similar for SlideShare. After an hour or so, with JavaScript as my weapon and some simple techniques and approximations, SlideShare presentations were gestures ready. It took me around 30 lines to code to make SlideShare work via my gestures.
    Whats happening behind the scenes.

    • webRTC has made it possible to access the web camera directly from the browser. No Flash required!
    • A image is snapped at regular intervals.
    • HTML5 canvas is used to draw the current image.
    • The movement delta = The difference between the last image and the current image is calculated.
    • Depending on the value of delta, we try to detect which movement was done. Currently only for basic movements are supported: left, right, top, bottom.
    • Each of the directions are mapped with the SlideShare’s player API functions. Whenever, a movement is detected successfully, the player executes the mapped action.

    What are other features you’d like to see us develop in SlideShare Labs?

    { Comments on this entry are closed }

    Introducing SlideShare API Explorer

    by jai on November 19, 2012

    in Announcement,API/Mashups

    We know that at times it becomes difficult for you to keep up with our API documentation, which results in failed attempts at testing out an end point, and  in turn results in loss of productivity. To solve this issue, we created SlideShare API Explorer, which helps you get started with our API, and makes it super easy to test out an API endpoint.

    Just follow the simple steps below:

    1. Apply for an API key (requires a user account)- You’ll get the API credentials on your registered email address.
    2. Go to apiexplorer.slideshare.net and fill in your credentials which you have received in the email.

    Fill in your API Credentials

    3. Now select an endpoint to test, fill in test parameters and click on ‘try it’. It will query our endpoint and show the generated query string, response headers and response body.

    We are constantly working on making the API development workflow a seamless experience for you, and would love to hear your feedback/suggestions on this, feel free to share your comments below.

    { Comments on this entry are closed }

    DevelopHer Hackday Delhi

    by Jeba Singh Emmanuel on June 22, 2012

    in Uncategorized

    DevelopHer Hackday Delhi
    Announcing DevelopHer Hackday Delhi at SlideShare’s New Delhi office. First of its kind event! Same dates as DevelopeHer Hackday in the Bay Area organized by LinkedIn. Come on women geeks and hackers.. this is your stage! Form a team, code all night, create something awesome, and present it to the judges to win prizes.

    Dave McClure (silicon valley guru, investor & founder of 500startups) and Rashmi Sinha will be judging the event. Participants in the winning team get an Apple Macbook Air each. Participants in the team winning the Second Prize get Apple iPads.

    Are you ready? If you have not registered yet, hurry and register at http://hackday.linkedin.com/developher/delhi for the Hackday on Saturday, June 30th and Sunday, July 1st.

    DevelopHer is being organised by LinkedIn at its Mountain View office. DevelopHer Hackday Delhi is a parallel event being organised by SlideShare (which is a part of LinkedIn now) at their New Delhi office

    { Comments on this entry are closed }

    SlideShare is looking for Rockstar Designers in New Delhi

    February 20, 2012

    [Reposted from the SlideShare Blog http://blog.slideshare.net/2012/02/17/designer-dream-job-in-delhi/] Are you passionate about digital design? Do you dream of working at one of the world’s fastest growing startups? If you are an experienced web or interactive designer, come work with SlideShare in our New Delhi office. You’ll be collaborating closely with our software developers, product managers, and analysts […]

    Read more →

    6 foot clownfish swimming through the slideshare sf office

    January 25, 2012

    So we got one of those awesome thinkgeek toys a couple weeks ago … a huge remote-control fish. Amazingly, it propels itself by swimming … it doesn’t have a propeller or anything. As a result it looks amazingly realistic and is a lot of fun to drive. Here’s a video of it in action. Floating […]

    Read more →

    The buddy system: an alternative to pair programming

    November 28, 2011

    Pair programming has always rubbed me the wrong way. I understand why some people like it. It’s great to have collective code ownership. It’s great to have conversations about what the code should look like before the code is actually written. And it’s great to have a collaborative work environment where people are always learning […]

    Read more →

    Using sounds for ambient alerting in a web startup

    October 13, 2011

    Over the last few weeks, Sylvain Kalache built a sound alerting system for the SlideShare office. What it does is make various noises in the slideshare office when a new subscription user signs up, cancels, or renews. It also makes sounds when a build fails, when a deployment to production starts, and when a deployment […]

    Read more →