HomeHome  
  • WelcomeWelcome  
  • Events  
  • PublicationsPublications  
  • FAQFAQ  
  • SearchSearch  
  • MemberlistMemberlist  
  • UsergroupsUsergroups  
  • RegisterRegister  
  • Log inLog in  
  • You are not connected. Please login or register


    Page load timer

    avatar
    • Administrator

        Reputation : 315
        Registered on : 2012-02-22
        Posts : 2362
        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

      avatar
      • 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. :)

        avatar
        • Administrator

            Reputation : 315
            Registered on : 2012-02-22
            Posts : 2362
            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

          • **


              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.

            avatar
            • **


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

              avatar
              • **


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


                YOUR BANNER HERE
                728x90
                DMCA.com Protection Status
                © PunBB | Contact | Report an abuse