Skip to content

Commit d1c9c32

Browse files
committed
1.7.10
added 'nocookie' option to youtube loader (#165)
1 parent f400244 commit d1c9c32

11 files changed

+30
-22
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ Some examples below:
6565
Lazy and all plugins are available over [cdnjs](http://cdnjs.com) and [jsDelivr](http://jsdelivr.com) CDN and can directly included to every page.
6666
```HTML
6767
<!-- jsDeliver -->
68-
<script type="text/javascript" src="//cdn.jsdelivr.net/gh/eisbehr-/jquery.lazy@1.7.9/jquery.lazy.min.js"></script>
69-
<script type="text/javascript" src="//cdn.jsdelivr.net/gh/eisbehr-/jquery.lazy@1.7.9/jquery.lazy.plugins.min.js"></script>
68+
<script type="text/javascript" src="//cdn.jsdelivr.net/gh/eisbehr-/jquery.lazy@1.7.10/jquery.lazy.min.js"></script>
69+
<script type="text/javascript" src="//cdn.jsdelivr.net/gh/eisbehr-/jquery.lazy@1.7.10/jquery.lazy.plugins.min.js"></script>
7070

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

7676
#### Self-Hosted

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jquery-lazy",
33
"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.",
4-
"version": "1.7.9",
4+
"version": "1.7.10",
55
"main": "jquery.lazy.min.js",
66
"license": [
77
"MIT",

jquery.lazy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* jQuery & Zepto Lazy - v1.7.9
2+
* jQuery & Zepto Lazy - v1.7.10
33
* http://jquery.eisbehr.de/lazy/
44
*
55
* Copyright 2012 - 2018, Daniel 'Eisbehr' Kern

jquery.lazy.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jquery.lazy.plugins.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@
574574
})(window.jQuery || window.Zepto);
575575

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

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

600601
else {
601602
// pass error state
602-
// use response function for Zepto
603603
response(false);
604604
}
605605
});

jquery.lazy.plugins.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jquery-lazy",
33
"title": "jQuery & Zepto Lazy - Delayed Content, Image and Background Loader",
4-
"version": "1.7.9",
4+
"version": "1.7.10",
55
"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.",
66
"main": "jquery.lazy.js",
77
"homepage": "http://jquery.eisbehr.de/lazy",

plugins/README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -283,18 +283,26 @@ There is no way to check if the video was loaded correctly or your provided vide
283283

284284
## YouTube Video Loader
285285
**Names:** `yt`, `youtube`
286-
**Parameters:** `data-src`
286+
**Parameters:** `data-src`, `data-nocookie`
287287
**Default for:** -
288288

289289
Loads youtube videos in an `<iframe>`.
290290
This is the suggested way by youtube itself.
291291
You can prepare the `<iframe>` element as you would do without Lazy.
292292
Only add the youtube video id to the attribute `data-src` and add the loader name.
293293
That's all.
294+
294295
```HTML
295296
<iframe data-loader="youtube" data-src="1AYGnw6MwFM" width="560" height="315" frameborder="0"></iframe>
296297
```
297298

299+
If you want to, you can control the cookie behavior of the embedded video with `data-nocookie="1"`.
300+
This would change the url to `youtube-nocookie.com` instead of `youtube.com`.
301+
302+
```HTML
303+
<iframe data-loader="youtube" data-src="1AYGnw6MwFM" data-nocookie="1" width="560" height="315" frameborder="0"></iframe>
304+
```
305+
298306
**Please keep in mind:**
299307
Because this is an iframe and there is no feedback javascript could check on, this loader can only return success to Lazy.
300308
There is no way to check if the video was loaded correctly or your provided video id is existing.

0 commit comments

Comments
 (0)