aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2014-08-02 19:57:15 +0200
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2014-08-02 19:57:15 +0200
commit274c8096e3ccc8ea008c1a038134ffddc302fd0d (patch)
treebec4006e995fa2e25026631b9a686149ae978956 /lib
parent6bbf7d51cf19203517b5b0d3ba20b1cc30eb7628 (diff)
Experimental: Removed lazyload.js and use postpone attribute instead
https://github.com/marienfressinaud/FreshRSS/issues/316 The performance of lazyload.js was not good enough, and not really needed anyway. This change mostly affects mainly situations when the content of articles is shown by default, not so much when they are collapsed Using HTML5 lazyload and postpone attributes by default on all img, audio, iframe, video. http://www.w3.org/TR/resource-priorities/#attr-postpone Postpone attribute is removed by JavaScript if the user does not want the lazyload behaviour. In the case when users do want the lazyload behaviour, in normal view with articles hidden, we furthermore use the data-original approach to be sure to support current browsers. +Corrected some bugs with enclosures, and some images not appearing before the first scroll. +Now faster regex processing img and iframe at once (was not practical with lazyload.js)
Diffstat (limited to 'lib')
-rw-r--r--lib/lib_rss.php20
1 files changed, 6 insertions, 14 deletions
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index 7ca611b04..86c0a4ae4 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -121,10 +121,10 @@ function customSimplePie() {
'onmouseover', 'onmousemove', 'onmouseout', 'onfocus', 'onblur',
'onkeypress', 'onkeydown', 'onkeyup', 'onselect', 'onchange', 'seamless')));
$simplePie->add_attributes(array(
- 'img' => array('lazyload' => ''), //http://www.w3.org/TR/resource-priorities/
- 'audio' => array('preload' => 'none'),
- 'iframe' => array('postpone' => '', 'sandbox' => 'allow-scripts allow-same-origin'),
- 'video' => array('postpone' => '', 'preload' => 'none'),
+ 'img' => array('lazyload' => '', 'postpone' => ''), //http://www.w3.org/TR/resource-priorities/
+ 'audio' => array('lazyload' => '', 'postpone' => '', 'preload' => 'none'),
+ 'iframe' => array('lazyload' => '', 'postpone' => '', 'sandbox' => 'allow-scripts allow-same-origin'),
+ 'video' => array('lazyload' => '', 'postpone' => '', 'preload' => 'none'),
));
$simplePie->set_url_replacements(array(
'a' => 'href',
@@ -183,16 +183,8 @@ function get_content_by_parsing ($url, $path) {
*/
function lazyimg($content) {
return preg_replace(
- '/<img([^>]+?)src=[\'"]([^"\']+)[\'"]([^>]*)>/i',
- '<img$1src="' . Minz_Url::display('/themes/icons/grey.gif') . '" data-original="$2"$3>',
- $content
- );
-}
-
-function lazyIframe($content) {
- return preg_replace(
- '/<iframe([^>]+?)src=[\'"]([^"\']+)[\'"]([^>]*)>/i',
- '<iframe$1src="about:blank" data-original="$2"$3>',
+ '/<((?:img|iframe)[^>]+?)src=[\'"]([^"\']+)[\'"]([^>]*)>/i',
+ '<$1src="' . Minz_Url::display('/themes/icons/grey.gif') . '" data-original="$2"$3>',
$content
);
}