Jump to content

[SOLVED] Load Time - Show load time on front office


vontanix
 Share

Recommended Posts

you can use tools like pingdom , gtmetrix or webpagetest for front office. This is generally a better way to test since it will not take into account any browser caching from your machine. Also google's pagespeed insights (as well as dev console on chrome / firefox) is a great tool to find reasons your shop might be slow (although it will not display specific load times).

  • Like 1

Share this post


Link to post
Share on other sites

But I expect you want to SHOW the load time on the page, not only find out how much time it takes, right?

 

If so, do the following:

 

edit/override file: classes/controllers/FrontController.php

in function construct, add red code:

 

public function __construct()
{
    global $timer_start;
    $this->timer_start = $timer_start;
 
 
Then in the same file, in function  initFooter, add:
public function initFooter()
{
    $this->context->smarty->assign(array(
    'timer_start' => $this->timer_start,
    'HOOK_FOOTER' => Hook::exec('displayFooter'),
 

 

Then in file /index.php, add:

 

$timer_start = microtime(true);
require(dirname(__FILE__).'/config/config.inc.php');
Dispatcher::getInstance()->dispatch();
 

 

Finally, edit file:  themes/default-bootstrap/footer.tpl, and add red code, somewhere at the end:

 

{if isset($HOOK_FOOTER)}
    <!-- Footer -->
        <div class="footer-container">
            <footer id="footer"  class="container">
                <div class="row">{$HOOK_FOOTER}</div>
            </footer>
            <span id="footer-load-time"><i class="icon-time" title="{l s='Load time: '}"></i> {number_format(microtime(true) - $timer_start, 3, '.', '')}s</span>
        </div>
    <!-- #footer -->
{/if}
 
 
Code is almost similar to admin timer, so I expect that is what you needed,
 
pascal.
  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More