Edit in JSFiddle

window.onload = function()
{
    if("performance" in window)
    {
        if("timing" in window.performance)
        {
             document.getElementById("result").innerHTML = "Page Performance API supported";
             document.getElementById("total_download_time").innerHTML = "Total  time taken to download the webpage from server is : " + (window.performance.timing.responseEnd - window.performance.timing.navigationStart) + " milliseconds";
            document.getElementById("total_render_time").innerHTML = "Total  time taken to render the webpage  is : " + (window.performance.timing.loadEventStart - window.performance.timing.domLoading) + " milliseconds";
        }
        else
        {
             document.getElementById("result").innerHTML = "Page Timing API not supported";
        }
    }
    else
    {
        document.getElementById("result").innerHTML = "Page Performance API not supported";
    }
}
<div id="result"></div>
<div id="total_download_time"></div>
<div id="total_render_time"></div>