Giter Club home page Giter Club logo

youtube-lite-embed's Introduction

Overview

Designed with performance in mind, "YouTube Lite Embed" is a jQuery library that allows you to embed YouTube videos in a light-weight fashion that has minimum impact on the page initial load speed. This library is definitely aimed at YouTube embed freaks and targets pages that contain loads of embedded YouTube content.

Functionality

HTML embedded content especially flash content, takes a significant time to load which decreases the overall page load speed. As more embedded objects are added to the page, this could literally spell page load chaos. This library addresses this issue by not directly loading YouTube embedded content. Instead, video thumbnails and titles are fetched using the YouTube Data API then placed in such a way that makes it look like the YouTube embedded player layout. Moreover with the aid of the jQuery lazy load plugin, these fetched thumbnails are only rendered using Ajax when the user scrolls to see them thus, the thumbnails loading time is also eliminated.

Usage

  1. import "jQuery" & the "lazy load" plugin if you haven't:

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script type="text/javascript" src="jquery.lazyload.min.js"></script>
    
  2. import the "YouTube Lite Embed" Plugin:

    <script type="text/javascript" src="lite-youtube-min.js"></script>
    
  3. Add the following CSS Rules:

    <style>
    	div.lite {
    		position: relative; left: 0; top: 0
    	}
    	img.lite:hover {
    		background:url(http://lh5.googleusercontent.com/-oBFjswrosz4/TuHqainRc3I/AAAAAAAAAbE/t3rMQuSJdLA/s800/youtube-play-button-hover.png)
    	}
    </style>
    
  4. Finally, you can simply embed a youtube video anywhere using the following markup:

    <div class="lite" id="youtube_video_id" style="width:my_width;height:my_height;"></div>
    

    Where:

    • youtube_video_id is the id of that video. (Typically, the value after 'v=' in the URL)
    • my_width and my_height are the width and height of the embedded player in either pixels (Ex: 360px) or percetage (Ex: 50%).

    Alternatively, you can install this chrome extension that I coded which will automatically copy the aforementioned special markup code to your clipboard whenever you click it's icon whilst being at a youtube video page.

Demos

Benchmarks

The best way to test it out is to check the demos above. You'll instantly feel the difference especially if you are a *nix user.

"There are three types of lies: lies, damned lies and benchmarks"

That being said, let's get down to the results =)

Without the lite embed library, the page took 7.721s to fully load without caching. On the other hand, the page took ONLY 1.263s to load using the library under the same benchmark configuration. This is 6.1x Faster !!!. (PS: this was only tested on a page that has 10 videos. Try it with more videos and be impressed)

  • Benchmark summary using the library:

    Document Complete Fully Loaded
    Load Time First Byte Start Render Time Requests Bytes In Time Requests Bytes In
    First View1.227s 0.190s 0.804s 1.227s 18 75 KB 1.263s 18 75 KB
    Repeat View 0.521s 0.196s 0.503s 0.521s 1 2 KB 0.865s 12 6 KB
    • Benchmark summary without the library:

      Document Complete Fully Loaded
      Load Time First Byte Start Render Time Requests Bytes In Time Requests Bytes In
      First View 0.947s 0.198s 0.000s 0.947s 3 39 KB 7.721s 28 602 KB
      Repeat View 0.556s 0.149s 0.000s 0.556s 2 6 KB 0.962s 12 41 KB
      • Detailed results can be fount at link1 and link2 for the "Using the library" and "Without the library" scenarios respectively.

youtube-lite-embed's People

Stargazers

Richie Bendall avatar vincent baker avatar Jeff Froom avatar Joël Galeran avatar  avatar Andrew Carpenter avatar Joseph Abrahams avatar Stanislav (Stas) Katkov avatar Pedro Coutinho avatar James Bao avatar Stefano DAmico avatar Amr Tj. Wallas avatar Gladson avatar Theun Kohlbeck avatar Thomas Prip Vestergaard avatar Vimal Atreya Ramaka avatar Alfredo Serafini avatar

Watchers

Pedro Coutinho avatar James Cloos avatar Amr Tj. Wallas avatar

youtube-lite-embed's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.