mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-10-20 02:11:52 -04:00
JS load optimization
Start loading what we can already before DOM is ready
This commit is contained in:
1 parent
b382f266de
commit
75d2fa3fd3
1 file changed
+34
-15
+34
-15
@@ -1294,27 +1294,46 @@ function parseJsonVars() {
|
||||
window.icons = json.icons;
|
||||
}
|
||||
|
||||
function init_all() {
|
||||
function init_beforeDOM() {
|
||||
if (!window.$) {
|
||||
if (window.console) {
|
||||
console.log('FreshRSS waiting for JS…');
|
||||
console.log('FreshRSS waiting for jQuery…');
|
||||
}
|
||||
window.setTimeout(init_all, 50);
|
||||
window.setTimeout(init_beforeDOM, 50);
|
||||
return;
|
||||
}
|
||||
parseJsonVars();
|
||||
init_notifications();
|
||||
init_confirm_action();
|
||||
if (['normal', 'reader', 'global'].indexOf(context['current_view']) >= 0) {
|
||||
$stream = $('#stream');
|
||||
if ($stream.length < 1) {
|
||||
if (window.console) {
|
||||
console.log('FreshRSS waiting for content…');
|
||||
}
|
||||
window.setTimeout(init_beforeDOM, 50);
|
||||
return;
|
||||
}
|
||||
init_column_categories();
|
||||
init_stream($stream);
|
||||
init_shortcuts();
|
||||
init_actualize();
|
||||
faviconNbUnread();
|
||||
}
|
||||
}
|
||||
|
||||
function init_afterDOM() {
|
||||
if (!window.$) {
|
||||
if (window.console) {
|
||||
console.log('FreshRSS waiting again for jQuery…');
|
||||
}
|
||||
window.setTimeout(init_afterDOM, 50);
|
||||
return;
|
||||
}
|
||||
init_notifications();
|
||||
$stream = $('#stream');
|
||||
if ($stream.length > 0) {
|
||||
init_actualize();
|
||||
init_column_categories();
|
||||
init_load_more($stream);
|
||||
init_posts();
|
||||
init_stream($stream);
|
||||
init_nav_entries();
|
||||
init_shortcuts();
|
||||
faviconNbUnread();
|
||||
init_print_action();
|
||||
init_notifs_html5();
|
||||
window.setInterval(refreshUnreads, 120000);
|
||||
@@ -1335,16 +1354,16 @@ function init_all() {
|
||||
}
|
||||
}
|
||||
|
||||
parseJsonVars();
|
||||
init_beforeDOM(); //Can be called before DOM is fully loaded
|
||||
|
||||
if (document.readyState && document.readyState !== 'loading') {
|
||||
if (window.console) {
|
||||
console.log('FreshRSS immediate init…');
|
||||
}
|
||||
init_all();
|
||||
init_afterDOM();
|
||||
} else if (document.addEventListener) {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
if (window.console) {
|
||||
console.log('FreshRSS waiting for DOMContentLoaded…');
|
||||
}
|
||||
init_all();
|
||||
init_afterDOM();
|
||||
}, false);
|
||||
}
|
||||
Reference in new issue
Block a user