Hello. I want to ask you for advice. There is a multipage site , a bunch of js scripts on the site, everything works well. But on one of the pages of the site (for registered users, in your account, ad page -> add ad) the script (just a modal fancybox) is very slow. On the remaining pages, everything works quickly and flawlessly (the link that calls the script is located in the header of the site). Slowly it loads on the page where there is a form that also selects cities, regions, etc. (code below). Data is taken from the context! In Chrome, the download takes 25-28 seconds. 2.5 seconds in FireFox enter image description here

{% load hosts %} <div class="b-header"> <div class="b-header__menu"> <div class="container"> <div class="row"> <div class="col-xs-12"> <div class="b-menu"> <a>...</a> <a>...</a> <a>...</a> <a>...</a> <span class="b-menu__item btn_change-location"> <a href="#change-location" class="fancybox dashed"> {% if user.is_authenticated %} Просмотр объявлений на территории: {% if user.districts.all.count > 1 %} {% for district in user.districts.all %} {% if forloop.last %} <span>{{ district }}</span> {% else %} <span>{{ district }},</span> {% endif %} {% endfor %} {% else %} {% for district in user.districts.all %} <span>{{ district }}</span> {% endfor %} {% endif %} {% if user.regions.all.count > 1 %} {% for region in user.regions.all %} {% if forloop.last %} <span>{{ region }}</span> {% else %} <span>{{ region }},</span> {% endif %} {% endfor %} {% else %} {% for region in user.regions.all %} <span>{{ region }}</span> {% endfor %} {% endif %} {% if user.cities.all.count > 1 %} {% for city in user.cities.all %} {% if forloop.last %} <span>{{ city }}</span> {% else %} <span>{{ city }},</span> {% endif %} {% endfor %} {% else %} {% for city in user.cities.all %} <span>{{ city }}</span> {% endfor %} {% endif %} {% else %} Просмотр объявлений на территории: {% endif %} </a> </span> </div> </div> </div> </div> </div> 

Template modals (data retrieval from content)

 {% load hosts %} {% load widget_tweaks static %} <div id="change-location"> <form action="{% host_url "setlocation" host "www" %}" method="post"> {% csrf_token %} <div id="chose-city-wrap"> <div class="b-modal__title">Выберите ваш город</div> <p> <div class="b-modal__item"> <span>{{ location_form.country.label }}</span> {{ location_form.country }} </div> </p> <p> <div class="b-modal__item"> <span>{{ location_form.districts.label }}</span> {{ location_form.districts }} </div> </p> <p> <div class="b-modal__item"> <span>{{ location_form.regions.label }}</span> {{ location_form.regions }} </div> </p> <p> <div class="b-modal__item"> <span>{{ location_form.cities.label }}</span> {{ location_form.cities }} </div> </p> <br /> <div class="b-modal__item b-modal__item_btn"> <input class="b-btn b-btn_red" type="submit" value="Сохранить"> </div> </div> </form> </div> 

Download cities on the page where modalka slows down!

 <fieldset> <legend>Территория распространения объявления</legend> {{ form.country|add_class:"b-input__input js-select" }} {{ form.districts|add_class:"b-input__input js-select chosen-select" }} {{ form.regions|add_class:"b-input__input js-select chosen-select" }} {{ form.cities|add_class:"b-input__input js-select chosen-select" }} {# form.geo|add_class:"b-input__input" #} </fieldset> 

Closed due to the fact that off-topic participants Anton Shchyrov , HamSter , Igor , Kromster , Denis Nov 9 Nov '16 at 6:45 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Anton Shchyrov, HamSter, Igor, Kromster, Denis
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • five
    Karma is bad, the programmer has a lousy mood, the spirits of the car are angry. Well, seriously, the question in the spirit of "why is my program not working?", Do not say without debugging. - Duck Learns to Take Cover
  • @ Duck I understand that everything is not telepathic here, it may just happen that someone, what could be the reasons for this behavior, when everything works fine, and on one page it loads the script for about 10 seconds ... - b-ars07
  • so long what's going on? loads the script over the network? house redraw? or logic hangs? Or is some crap memory clogged? or for example with a script in addition loaded porn with horses? (Well, not to download it, this icon for the "close" button should be taken from somewhere). In the developer console, there are tools for debugging all this - Duck Learns to Take Cover
  • For just the template code, it is impossible to reproduce the problem, give something that we will run and that we will also slow down - andreymal
  • @ b-ars07, clear the browser's cache, open the developer’s tools in the browser on the “network” tab and load the page of your site. Show this temporary loading pattern. - Visman

1 answer 1

If the script is in the header, then it is worth seeing what is loaded in front of it. These are probably css and other scripts. On this page in the css some big pictures may be indicated, for example. Look at the network tab in the developer console to see exactly what is being loaded.