Answer the question
In order to leave comments, you need to log in
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;
?>
Answer the question
In order to leave comments, you need to log in
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.
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 questionAsk a Question
731 491 924 answers to any question