Resolving part of the page in arrears

2

The pages of a project that I have are having a strange behavior, when being called a page snippet is being loaded, apparently late, the code is this:

  <div class="page-banner no-subtitle">
<div class="container">
  <div class="row">
    <div class="col-md-6">
      <h2>PRODUTOS</h2>
    </div>
    <div class="col-md-6">
      <ul class="breadcrumbs">
        <li><a href="index.php">Início</a></li>
        <li>Produtos</li>
      </ul>
    </div>
  </div>
</div>

Well at the top of the page I have this:

<div class="hidden-header"></div>

And it is associated with .js , which is this:

var headerEle = function(){
    var $headerHeight = $('header').height();
    $('.hidden-header').css({ 'height' : $headerHeight  + "px" });
};

$(window).load(function () {
  headerEle();
});

$(window).resize(function () {
   headerEle();
});

The page has a delay in loading, I tried some options and nothing worked, if I remove or comment the code .js and page-banner some.

An example of the behavior can be seen here

    
asked by anonymous 02.12.2015 / 19:09

2 answers

2

I took a look at your code:

  • Put all JavaScript at the end of the page, before closing the tag s of </body> . Doing so implies that JavaSccript has to wait for the DOM to fully load so that it can then execute.
  • I saw that you have a <div></div> of page load, the one that is running loader . Please use it in your favor:

$(window).on('load', function () {
    $("#loader").hide("slow");
});

By doing this, you force%

02.12.2015 / 19:29
1

The loader solution is good, but I doubt that such a small JS will delay page loading.

Ideally, you should first find out what is delaying page load before deciding what to do to resolve it.

Using Chrome (or Firefox) press < ctrl > + < shift > + < i & gt ;. Click the "Network" (or Network, depending on the language) option and reload your page.

You will be able to see graphically what is holding this shipment. Once you know this, it will be easier to give some suggestion of what can be done to improve performance.

    
02.12.2015 / 19:51