All Projects → vb → Lazyframe

vb / Lazyframe

Licence: mit
🛀🏽 Dependency-free library for lazyloading iframes

Programming Languages

javascript
184084 projects - #8 most used programming language
es6
455 projects

Projects that are alternatives of or similar to Lazyframe

Modal Video
Stars: ✭ 224 (-5.49%)
Mutual labels:  vimeo, youtube
React Native Youtube Iframe
A wrapper of the Youtube-iframe API built for react native.
Stars: ✭ 221 (-6.75%)
Mutual labels:  youtube, iframe
Unity Videoplayer Helper
Simple helper for the Video Player in Unity
Stars: ✭ 49 (-79.32%)
Mutual labels:  vimeo, youtube
Plyr
Plyr Mediaplayer (Video und Audio) im Front- und Backend
Stars: ✭ 30 (-87.34%)
Mutual labels:  vimeo, youtube
Vime
Customizable, extensible, accessible and framework agnostic media player. Modern alternative to Video.js and Plyr. Supports HTML5, HLS, Dash, YouTube, Vimeo, Dailymotion...
Stars: ✭ 1,928 (+713.5%)
Mutual labels:  vimeo, youtube
Yaydl
yet another youtube down loader (Git mirror)
Stars: ✭ 45 (-81.01%)
Mutual labels:  vimeo, youtube
Ac D3
Javascript Library for building Audiovisual Charts in D3
Stars: ✭ 76 (-67.93%)
Mutual labels:  vimeo, youtube
Podsync
Turn YouTube or Vimeo channels, users, or playlists into podcast feeds
Stars: ✭ 657 (+177.22%)
Mutual labels:  vimeo, youtube
React Modal Video
Accessible React Modal Video Component
Stars: ✭ 105 (-55.7%)
Mutual labels:  vimeo, youtube
Socialcounters
jQuery/PHP - Collection of Social Media APIs that display number of your social media fans. Facebook Likes, Twitter Followers, Instagram Followers, YouTube Subscribers, etc..
Stars: ✭ 104 (-56.12%)
Mutual labels:  vimeo, youtube
Richtextview
iOS Text View (UIView) that Properly Displays LaTeX, HTML, Markdown, and YouTube/Vimeo Links
Stars: ✭ 953 (+302.11%)
Mutual labels:  vimeo, youtube
Workflowshare
Workflow实例分享
Stars: ✭ 137 (-42.19%)
Mutual labels:  vimeo, youtube
Raspberrycast
📺 Transform your Raspberry Pi into a streaming device. Videos can be sent from mobile devices or computers (Chrome extension).
Stars: ✭ 726 (+206.33%)
Mutual labels:  vimeo, youtube
Kaku
🎧 Kaku is a highly integrated music player supports different online platform like YouTube, SoundCloud, Vimeo and more. Available on Mac, Windows and Linux.
Stars: ✭ 1,028 (+333.76%)
Mutual labels:  vimeo, youtube
Bigpicture
Lightweight JavaScript image / video viewer. Supports Youtube, Vimeo, etc.
Stars: ✭ 722 (+204.64%)
Mutual labels:  vimeo, youtube
Network Avatar Picker
A npm module that returns user's social network avatar. Supported providers: facebook, instagram, twitter, tumblr, vimeo, github, youtube and gmail
Stars: ✭ 74 (-68.78%)
Mutual labels:  vimeo, youtube
Yt Player
Simple, robust, blazing-fast YouTube Player API
Stars: ✭ 576 (+143.04%)
Mutual labels:  youtube, iframe
Superembed.js
Fluid width for YouTube, Vimeo, Vine, VideoPress, DailyMotion, and more embedded videos.
Stars: ✭ 615 (+159.49%)
Mutual labels:  vimeo, youtube
Plyr React
A simple, accessible and customisable react media player for Video, Audio, YouTube and Vimeo
Stars: ✭ 89 (-62.45%)
Mutual labels:  vimeo, youtube
Alltube
Web GUI for youtube-dl
Stars: ✭ 1,925 (+712.24%)
Mutual labels:  vimeo, youtube

Lazyframe

npm version

Dependency-free library for lazyloading iframes. Demo

Why?

Because embedded content takes time to load.

  • Youtube – 11 requests ≈ 580kb
  • Google maps – 52 requests ≈ 580kb
  • Vimeo – 8 requests ≈ 145kb

Lazyframe creates a responsive placeholder for embedded content and requests it when the user interacts with it. This decreases the page load and idle time.

Lazyframe comes with brand-like themes for Youtube, Vimeo and Vine.

  1. Install
  2. Import
  3. Initialize
  4. Options

Install

NPM

$ npm install lazyframe --save

Bower

$ bower install lazyframe

Import

JavaScript ES6 imports

import lazyframe from 'lazyframe';

Include JavaScript in html

<script src="dist/lazyframe.min.js"></script>

Sass import

@import 'src/scss/lazyframe';

Include css in html

<link rel="stylesheet" href="dist/lazyframe.css">

Initialize

// Passing a selector
lazyframe('.lazyframe');

// Passing a nodelist
let elements = document.querySelectorAll('.lazyframe');
lazyframe(elements);

// Passing a jQuery object
let elements = $('.lazyframe');
lazyframe(elements);

Options

You can pass general options to lazyframe on initialization. Element-specific options (most options) are set on data attributes on the element itself.

General options and corresponding defaults

lazyframe(elements, {
   apikey: undefined,
   debounce: 250,
   lazyload: true,

   // Callbacks
   onLoad: (lazyframe) => console.log(lazyframe),
   onAppend: (iframe) => console.log(iframe),
   onThumbnailLoad: (img) => console.log(img)
})

apikey

If you want to load a thumbnail and title for a YouTube video you'll have to have an API key with the YouTube data API library enabled. Get it from here

If you don't feel like getting a key, just use your own thumbnail and title in data-thumbnail and data-title attribute

debounce

Value (in milliseconds) for when the update function should run after the user has scrolled. More here

lazyload

Set this to false if you want all API calls and local images to be loaded on page load (instead of when the element is in view).

onLoad

Callback function for when a element is initialized.

onAppend

Callback function for when the iframe is appended to DOM.

onThumbnailLoad

Callback function with the thumbnail URL

Element-specific options

<div
    class="lazyframe"
    data-vendor=""
    data-title=""
    data-thumbnail=""
    data-src=""
    data-ratio="1:1"
    data-initinview="false">
</div>

data-vendor

Attribute for theming lazyframe. Currently supported values are youtube, youtube_nocookie, vimeo and vine.

data-title

Attribute for custom title. Leave empty to get value from API.

data-thumbnail

Attribute for custom thumbnail. Leave empty to get value from API.

data-src

The source of what you want to lazyload.

data-ratio

The ratio of the lazyframe. Possible values: 16:9, 4:3, 1:1

data-initinview

Set this to true if you want the resource to execute (for example video to play) when the element is in view.

License

MIT. © 2016 Viktor Bergehall

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].