# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)

# ---------- Page Load Speed-Up -----------------------------------------------------------------------------------
#
# Dependencies : -
# Resources    : -
# Preferences  : -
#
# ------------------------------------------------------------------------------------------------------------------

SpeedUp_Toggle{
menuchecked=(getpref(BOOL,"network.http.pipelining")==true);
getpref(BOOL,"network.http.pipelining")==true?&_SpeedUp_Disable:&_SpeedUp_Enable;
}

# ----- PRIVATE

_SpeedUp_Enable{
statusbar(sub("%s",$on,_("Page load speed-up %s")));

# TURN ON TIMER BASED REFLOW MANAGEMENT
setpref(BOOL,"content.notify.ontimer",true);

# SETS THE ALLOWED TIME BETWEEN REFLOWS IN MICROSECONDS
setpref(INT, "content.notify.interval",240000);

# SET THE NUMBER OF REFLOWS TO DO BEFORE WAITING FOR THE REST OF THE PAGE TO ARRIVE
setpref(INT, "content.notify.backoffcount",10);

# ENABLE IMPROVED PIPELINING
setpref(BOOL,"network.http.pipelining",true);
setpref(INT, "network.http.pipelining.maxrequests",10);
setpref(BOOL,"network.http.proxy.pipelining",true);

# INCREASE MULTI-THREADED DOWNLOAD PERFORMANCE
setpref(INT, "network.http.max-connections",40);
setpref(INT, "network.http.max-connections-per-server",32);
setpref(INT, "network.http.max-persistent-connections-per-proxy",16);
setpref(INT, "network.http.max-persistent-connections-per-server",8);
}

_SpeedUp_Disable{
statusbar(sub("%s",$off,_("Page load speed-up %s")));

# RESTORE DEFAULTS
delpref("content.notify.ontimer");
delpref("content.notify.interval");
delpref("content.notify.backoffcount");
delpref("network.http.pipelining");
delpref("network.http.pipelining.maxrequests");
delpref("network.http.proxy.pipelining");
delpref("network.http.max-connections");
delpref("network.http.max-connections-per-server");
delpref("network.http.max-persistent-connections-per-proxy");
delpref("network.http.max-persistent-connections-per-server");
}

_SpeedUp_BuildMenu{
# tools menu
setmenu("&Tools",macro,"Page Load &Speed-Up",SpeedUp_Toggle);
}
$OnInit=$OnInit."_SpeedUp_BuildMenu;";

# ------------------------------------------------------------------------------------------------------------------
$macroModules=$macroModules."SpeedUp;";
