page load perfomance improvements...
remove the lists.js file from the <head>, which slows down page load a lot (over 300K), and instead load it dynamically on page load. also remove navtree_data.js from the <head>, which also slows the load and is only used in the reference when in tree view. This file is now loaded during the initialization of the nav tree.
This commit is contained in:
parent
39528d6bac
commit
5b53cd78cd
4 changed files with 26 additions and 6 deletions
|
@ -151,8 +151,9 @@ def:default_left_nav() ?>
|
|||
if (!isMobile) {
|
||||
$("<a href='#' id='nav-swap' onclick='swapNav();return false;' style='font-size:10px;line-height:9px;margin-left:1em;text-decoration:none;'><span id='tree-link'>Use Tree Navigation</span><span id='panel-link' style='display:none'>Use Panel Navigation</span></a>").appendTo("#side-nav");
|
||||
chooseDefaultNav();
|
||||
if ($("#nav-tree").is(':visible')) init_navtree("nav-tree", "<?cs var:toroot ?>", NAVTREE_DATA);
|
||||
else {
|
||||
if ($("#nav-tree").is(':visible')) {
|
||||
init_default_navtree("<?cs var:toroot ?>");
|
||||
} else {
|
||||
addLoadEvent(function() {
|
||||
scrollIntoView("packages-nav");
|
||||
scrollIntoView("classes-nav");
|
||||
|
|
|
@ -31,6 +31,15 @@ if ((agent.indexOf("Mobile") != -1) ||
|
|||
addLoadEvent(mobileSetup);
|
||||
}
|
||||
|
||||
/* loads the lists.js file to the page.
|
||||
Loading this in the head was slowing page load time */
|
||||
addLoadEvent( function() {
|
||||
var lists = document.createElement("script");
|
||||
lists.setAttribute("type","text/javascript");
|
||||
lists.setAttribute("src", toRoot+"reference/lists.js");
|
||||
$("head").append($(lists));
|
||||
} );
|
||||
|
||||
window.onresize = resizeAll;
|
||||
|
||||
function mobileSetup() {
|
||||
|
@ -282,7 +291,7 @@ function swapNav() {
|
|||
nav_pref = NAV_PREF_PANELS;
|
||||
} else {
|
||||
nav_pref = NAV_PREF_TREE;
|
||||
init_navtree("nav-tree", toRoot, NAVTREE_DATA);
|
||||
init_default_navtree(toRoot);
|
||||
}
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime()+(10*365*24*60*60*1000)); // keep this for 10 years
|
||||
|
|
|
@ -144,8 +144,20 @@ function find_page(url, data)
|
|||
return null;
|
||||
}
|
||||
|
||||
function load_navtree_data(toroot) {
|
||||
var navtreeData = document.createElement("script");
|
||||
navtreeData.setAttribute("type","text/javascript");
|
||||
navtreeData.setAttribute("src", toroot+"navtree_data.js");
|
||||
$("head").append($(navtreeData));
|
||||
}
|
||||
|
||||
function init_default_navtree(toroot) {
|
||||
load_navtree_data(toroot);
|
||||
init_navtree("nav-tree", toroot, NAVTREE_DATA);
|
||||
}
|
||||
|
||||
function init_navtree(navtree_id, toroot, root_nodes)
|
||||
{
|
||||
{
|
||||
var me = new Object();
|
||||
me.toroot = toroot;
|
||||
me.node = new Object();
|
||||
|
|
|
@ -11,14 +11,12 @@ else ?>
|
|||
<link href="<?cs var:toroot ?>assets/android-developer-docs.css" rel="stylesheet" type="text/css" /><?cs
|
||||
/if ?>
|
||||
<script src="<?cs var:toroot ?>assets/search_autocomplete.js" type="text/javascript"></script>
|
||||
<script src="<?cs var:toroot ?>reference/lists.js" type="text/javascript"></script>
|
||||
<script src="<?cs var:toroot ?>assets/jquery-resizable.min.js" type="text/javascript"></script>
|
||||
<script src="<?cs var:toroot ?>assets/android-developer-docs.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
setToRoot("<?cs var:toroot ?>");
|
||||
</script><?cs
|
||||
if:reference ?>
|
||||
<script src="<?cs var:toroot ?>navtree_data.js" type="text/javascript"></script>
|
||||
<script src="<?cs var:toroot ?>assets/navtree.js" type="text/javascript"></script><?cs
|
||||
/if ?>
|
||||
<noscript>
|
||||
|
|
Loading…
Reference in a new issue