Niko
  • Administrator

      Reputation : 319
      Registered on : 2012-02-22
      Posts : 2366
      School of codes courses: coming soon
    Page load timer

    Description


    Have you ever wanted a script that counts how long it takes for your webpage to load? Like the one when you google search and it says (X seconds)? Check out the quick tutorial below.

    Set up


    Put this code below your tag:
    Code:
    <script language="Javascript">
    beforeload = (new Date()).getTime();
    function pageloadingtime()
    {
            afterload = (new Date()).getTime();
            secondes = (afterload-beforeload)/1000;
            window.status='The page took  [' + secondes + '] seconds to load.';
            document.getElementById("loadingtime").innerHTML = "<font style='color:red;'>The page took [<b>" + secondes + "</b>] seconds to load.</font>";
    }
    window.onload = pageloadingtime;
    </script>


    Put this code where you want the text/stat to show up:
    Code:
    Code:
    <font id="loadingtime"></font>


    Technical problems


    The tutorial was tested on this forum and with the browser Google Chrome; If you notice that the tutorial doesn't work for a browser or for a version of forum (PhpBB2, PhpBB3, PunBB, Invision) contact an administrator and we will fill this field with your reporting.

    Thanks, the staff
    For every problem or question please, contact us in the section Support for the tutorials, The staff will answer you as soon as it is possible...



    Niko wants you in the team Guest

    Community manager and Administrator at Forumattivo.com

    LGforum
    • Veteran staff member

        Reputation : 19
        Registered on : 2012-04-05
        Posts : 77
      Its a good idea this. For more accurate results, the Javascript should be taken out of the script tags and put in a JS file in javascript management. Then it will be much more accurate as to how long it actually took. :)

      Niko
      • Administrator

          Reputation : 319
          Registered on : 2012-02-22
          Posts : 2366
          School of codes courses: coming soon
        @LGforum wrote:Its a good idea this. For more accurate results, the Javascript should be taken out of the script tags and put in a JS file in javascript management. Then it will be much more accurate as to how long it actually took. :)
        Yss, you are right :bene:



        Niko wants you in the team Guest

        Community manager and Administrator at Forumattivo.com

        avatar
        • **


            Reputation : 0
            Registered on : 2012-04-08
            Posts : 20
          That is cool, but won't adding another javascript slow down the load time just a bit? Its a catch 22.

          dejanpetrus
          • **


              Reputation : 0
              Registered on : 2012-04-15
              Posts : 14
            no working for phpbb3

            GummyBear
            • **


                Reputation : 0
                Registered on : 2012-10-06
                Posts : 21
              Where should i put the 1st and 2nd code?