ソースを参照

Améliorations chargement JS async

En particulier pour global_view.js.
Suppression d'une requête avortée dans Chrome.
Alexandre Alapetite 12 年 前
コミット
4a999fb628
3 ファイル変更14 行追加6 行削除
  1. 2 2
      lib/http-conditional.php
  2. 10 3
      public/scripts/global_view.js
  3. 2 1
      public/scripts/main.js

+ 2 - 2
lib/http-conditional.php

@@ -151,7 +151,7 @@ function httpConditional($UnixTimeStamp,$cacheSeconds=0,$cachePrivacy=0,$feedMod
 		if ($cacheSeconds<0)
 		{
 			$cache='private, no-cache, no-store, must-revalidate';
-			header('Expires: 0');
+			//header('Expires: 0');
 			header('Pragma: no-cache');
 		}
 		else
@@ -159,7 +159,7 @@ function httpConditional($UnixTimeStamp,$cacheSeconds=0,$cachePrivacy=0,$feedMod
 			if ($cacheSeconds===0)
 			{
 				$cache='private, must-revalidate, ';
-				header('Expires: 0');
+				//header('Expires: 0');
 			}
 			elseif ($cachePrivacy===0) $cache='private, ';
 			elseif ($cachePrivacy===2) $cache='public, ';

+ 10 - 3
public/scripts/global_view.js

@@ -52,12 +52,19 @@ function init_global_view() {
 	init_stream_delegates($("#panel"));
 }
 
-if (document.readyState && document.readyState !== 'loading') {
+function init_all_global_view() {
+	if (!(window.$ && window.init_stream_delegates)) {
+		window.setTimeout(init_all_global_view, 50);	//Wait for all js to be loaded
+		return;
+	}
 	init_global_view();
 	init_close_panel();
+}
+
+if (document.readyState && document.readyState !== 'loading') {
+	init_all_global_view();
 } else if (document.addEventListener) {
 	document.addEventListener('DOMContentLoaded', function () {
-		init_global_view();
-		init_close_panel();
+		init_all_global_view();
 	}, false);
 }

+ 2 - 1
public/scripts/main.js

@@ -492,6 +492,7 @@ function init_load_more() {
 	url_load_more = $next_link.attr("href");
 	var $prefetch = $('#prefetch');
 	if ($prefetch.attr('href') !== url_load_more) {
+		$prefetch.attr('rel', 'next');	//Remove prefetch
 		$.ajax({url: url_load_more, ifModified: true });	//TODO: Try to find a less agressive solution
 		$prefetch.attr('href', url_load_more);
 	}
@@ -504,7 +505,7 @@ function init_load_more() {
 //</endless_mode>
 
 function init_all() {
-	if (!(window.$ && window.shortcut && ((!full_lazyload) || $.fn.lazyload))) {
+	if (!(window.$ && window.shortcut && window.shortcuts && ((!full_lazyload) || $.fn.lazyload))) {
 		if (window.console) {
 			console.log('Waiting for JS…');
 		}