I have developed a application for android using phonegap. I am loading external HTML pages using XMLHttpRequest . It is working fine but it takes time when i loading the external pages. How can i reduce the page loading time ?
My code as follows :
function loadHtmlPage(url){ //url - holds the name of the HTML page
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState === 4){
document.getElementById("externalpagecont").innerHTML = xmlhttp.responseText;
};
xmlhttp.open("GET", url , true);
xmlhttp.send(null);
}
From reading the comments, you are using an offine mobile application, and the
externalpages are actually local pages bundled with the app. So network latency is not your issue.If this is not the case, try including the pages in your www folder.
Assuming you have done that, one idea is to make your app be a single page and manipulate accordingly.
Then in javascript