Skip to content

Commit

Permalink
1.7.10
Browse files Browse the repository at this point in the history
added 'nocookie' option to youtube loader (#165)
  • Loading branch information
dkern committed Aug 31, 2018
1 parent f400244 commit d1c9c32
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 22 deletions.
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -65,12 +65,12 @@ Some examples below:
Lazy and all plugins are available over [cdnjs](http://cdnjs.com) and [jsDelivr](http://jsdelivr.com) CDN and can directly included to every page.
```HTML
<!-- jsDeliver -->
<script type="text/javascript" src="//cdn.jsdelivr.net/gh/eisbehr-/jquery.lazy@1.7.9/jquery.lazy.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/gh/eisbehr-/jquery.lazy@1.7.9/jquery.lazy.plugins.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/gh/eisbehr-/jquery.lazy@1.7.10/jquery.lazy.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/gh/eisbehr-/jquery.lazy@1.7.10/jquery.lazy.plugins.min.js"></script>

<!-- cdnjs -->
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.lazy/1.7.9/jquery.lazy.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.lazy/1.7.9/jquery.lazy.plugins.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.lazy/1.7.10/jquery.lazy.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.lazy/1.7.10/jquery.lazy.plugins.min.js"></script>
```

#### Self-Hosted
Expand Down
2 changes: 1 addition & 1 deletion bower.json
@@ -1,7 +1,7 @@
{
"name": "jquery-lazy",
"description": "Lazy is a fast, feature-rich and lightweight delayed content loading plugin for jQuery and Zepto. It's designed to speed up page loading times and decrease traffic to your users by only loading the content in view. You can use Lazy in all vertical and horizontal scroll ways. It supports images in 'img' tags and backgrounds, supplied with css like 'background-image', by default. On those elements Lazy can set an default image or a placeholder while loading and supports retina displays as well. But Lazy is even able to load any other content you want by plugins and custom loaders.",
"version": "1.7.9",
"version": "1.7.10",
"main": "jquery.lazy.min.js",
"license": [
"MIT",
Expand Down
2 changes: 1 addition & 1 deletion jquery.lazy.js
@@ -1,5 +1,5 @@
/*!
* jQuery & Zepto Lazy - v1.7.9
* jQuery & Zepto Lazy - v1.7.10
* http://jquery.eisbehr.de/lazy/
*
* Copyright 2012 - 2018, Daniel 'Eisbehr' Kern
Expand Down
2 changes: 1 addition & 1 deletion jquery.lazy.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions jquery.lazy.plugins.js
Expand Up @@ -574,7 +574,7 @@
})(window.jQuery || window.Zepto);

/*!
* jQuery & Zepto Lazy - YouTube Plugin - v1.4
* jQuery & Zepto Lazy - YouTube Plugin - v1.5
* http://jquery.eisbehr.de/lazy/
*
* Copyright 2012 - 2018, Daniel 'Eisbehr' Kern
Expand All @@ -585,11 +585,12 @@
*/
;(function($) {
// load youtube video iframe, like:
// <iframe data-loader="yt" data-src="1AYGnw6MwFM" width="560" height="315" frameborder="0" allowfullscreen></iframe>
// <iframe data-loader="yt" data-src="1AYGnw6MwFM" data-nocookie="1" width="560" height="315" frameborder="0" allowfullscreen></iframe>
$.lazy(['yt', 'youtube'], function(element, response) {
if (element[0].tagName.toLowerCase() === 'iframe') {
// pass source to iframe
element.attr('src', 'https://www.youtube.com/embed/' + element.attr('data-src') + '?rel=0&amp;showinfo=0');
var noCookie = /1|true/.test(element.attr('data-nocookie'));
element.attr('src', 'https://www.youtube' + (noCookie ? '-nocookie' : '') + '.com/embed/' + element.attr('data-src') + '?rel=0&amp;showinfo=0');

// remove attribute
if (this.config('removeAttribute')) {
Expand All @@ -599,7 +600,6 @@

else {
// pass error state
// use response function for Zepto
response(false);
}
});
Expand Down
4 changes: 2 additions & 2 deletions jquery.lazy.plugins.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "jquery-lazy",
"title": "jQuery & Zepto Lazy - Delayed Content, Image and Background Loader",
"version": "1.7.9",
"version": "1.7.10",
"description": "Lazy is a fast, feature-rich and lightweight delayed content loading plugin for jQuery and Zepto. It's designed to speed up page loading times and decrease traffic to your users by only loading the content in view.",
"main": "jquery.lazy.js",
"homepage": "http://jquery.eisbehr.de/lazy",
Expand Down
10 changes: 9 additions & 1 deletion plugins/README.md
Expand Up @@ -283,18 +283,26 @@ There is no way to check if the video was loaded correctly or your provided vide

## YouTube Video Loader
**Names:** `yt`, `youtube`
**Parameters:** `data-src`
**Parameters:** `data-src`, `data-nocookie`
**Default for:** -

Loads youtube videos in an `<iframe>`.
This is the suggested way by youtube itself.
You can prepare the `<iframe>` element as you would do without Lazy.
Only add the youtube video id to the attribute `data-src` and add the loader name.
That's all.

```HTML
<iframe data-loader="youtube" data-src="1AYGnw6MwFM" width="560" height="315" frameborder="0"></iframe>
```

If you want to, you can control the cookie behavior of the embedded video with `data-nocookie="1"`.
This would change the url to `youtube-nocookie.com` instead of `youtube.com`.

```HTML
<iframe data-loader="youtube" data-src="1AYGnw6MwFM" data-nocookie="1" width="560" height="315" frameborder="0"></iframe>
```

**Please keep in mind:**
Because this is an iframe and there is no feedback javascript could check on, this loader can only return success to Lazy.
There is no way to check if the video was loaded correctly or your provided video id is existing.
Expand Down

0 comments on commit d1c9c32

Please sign in to comment.