This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function lazy_embed_oembed_html($html, $url, $attr){ | |
| $html = str_replace('<iframe ','<iframe loading="lazy" ',$html); | |
| return $html; | |
| } | |
| add_filter('embed_oembed_html', 'lazy_embed_oembed_html',10, 3); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://codepen.io/cmykw/pen/gemxJm | |
| // layout | |
| <nav/> | |
| // style | |
| <style> | |
| body { min-height: 200vh; } | |
| nav { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // To open popup with ID 3 on same page (preferred) | |
| <a href="" class="spu-open-3" title="Click here">Click here</a> | |
| // Another way | |
| <a href="#spu-3" title="Click here">Click here</a> | |
| // To go to a new page and open a popup there | |
| <a href="http://mydomain.com/new-page/#spu-3" title="Click here">Click here</a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| </head> | |
| <body> | |
| <div style="text-align:center" onmouseover="Play()" onmouseout="Pause()"> | |
| <video id="video1" width="480"> | |
| <source src="http://clips.vorwaerts-gmbh.de/VfE_html5.mp4" type="video/mp4" /> | |
| <source src="http://clips.vorwaerts-gmbh.de/VfE_html5.ogg" type="video/ogg" /> | |
| Your browser does not support HTML5 video. | |
| </video> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Stop an iframe or HTML5 <video> from playing | |
| * @param {Element} element The element that contains the video | |
| */ | |
| var stopVideo = function ( element ) { | |
| var iframe = element.querySelector( 'iframe'); | |
| var video = element.querySelector( 'video' ); | |
| if ( iframe ) { | |
| var iframeSrc = iframe.src; | |
| iframe.src = iframeSrc; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| No jQuery necessary. | |
| Thanks to Dan's StackOverflow answer for this: | |
| http://stackoverflow.com/questions/123999/how-to-tell-if-a-dom-element-is-visible-in-the-current-viewport | |
| */ | |
| function isElementInViewport(el) { | |
| var rect = el.getBoundingClientRect(); | |
| return ( | |
| rect.top >= 0 && |