A
A
alexander_chn2017-05-18 23:52:42
1C-Bitrix
alexander_chn, 2017-05-18 23:52:42

Why does the slider take a long time to load in Bitrix?

Hello everybody! The situation is the following. The main page has a slider.
Here is the connection code:

<?
//подключаем слайдер на главной странице
if ( $APPLICATION->GetCurDir() == "/" ):
  if ( CModule::IncludeModule("iblock") ):
    // ID инфоблока из которого выводим элементы
      $iblock_id = 4;
      $my_slider = CIBlockElement::GetList (
        // Сортировка элементов
        Array("ID" => "ASC"),
        Array("IBLOCK_ID" => $iblock_id),
        false,
        false,
        // Перечисляесм все свойства элементов, которые планируем выводить
        Array(
        'ID', 
        'NAME', 
        'PREVIEW_PICTURE', 
        'PREVIEW_TEXT', 
        'PROPERTY_ATT_LINK'
        )
    );
     echo '<div class="top_main">';
      echo '<div class="in_top_main inner-wrap">';
        echo '<div class="owl-carousel">';
          while($ar_fields = $my_slider->GetNext())
          {
            //Выводим элемент со всеми свойствами + верстка
            $img_path = CFile::GetPath($ar_fields["PREVIEW_PICTURE"]);
            echo '<div class="item clearfix">';
              echo '<div class="slide_img_wrap">';
                 echo "<img src='".$img_path."'/>";
              echo '</div>';
              echo '<div class="slide_text_wrap">';
                echo "<span>" . $ar_fields['NAME'] . "</span>";
                echo '<a href="' . $ar_fields['PROPERTY_ATT_LINK_VALUE'] . '">' . 'Узнать больше' . '</a>';
              echo '</div>';
            echo '</div>';
          }
          echo '</div>';
        echo '</div>';
      echo '</div>';
  endif;
endif;
?>

Here is its general view: prntscr.com/f9fryh
The main content is loaded, and only then, as if the slider itself crashes between the header and the body of the site.
Pictures weigh 7 KB, that is, it is not through them that they take a long time to load.
Is it a matter of styles and js? But they are compressed, there is nowhere else to optimize. How to find out what is the reason?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya, 2017-05-19
@rpsv

In the browser console, look at the Network tab (for chrome), you can use it to understand what's going on: the scripts take a long time to load or the scripts themselves are executed only at the end of the page, therefore something else slows down the page.

A
Alexey Emelyanov, 2017-05-19
@babarun

Show the js code that initializes the slider. Perhaps the slider is created on the load event, and not ready.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question