Performance question: 400 controls on a page

16 views
Skip to first unread message

Yoda

unread,
Jul 10, 2015, 5:29:31 AM7/10/15
to django-s...@googlegroups.com
Hello,

I am using django-selectable on a bigger Web application and I am quite satisfied.
On some large page however I have a performance problem. One of them displays a table with 200 rows and each row contains two django-selectable controls. During the display of the page each control sends its Ajax request, receives the response, inserts it into the page which triggers a new layout of the whole page as it seems (in Firefox). Therefore the display of the page takes a couple a minutes to complete, the last rows taking much longer than the first rows.

I wonder whether it is possible to suppress the initial Ajax request as the data to display is already on the page. For example, if a save the page as a file and reload it, all the data is there in seconds without the requests. Or perhaps there are other means to load the page quicker?

Any help appreciated.
Thanks
yoda

Mark Lavin

unread,
Jul 10, 2015, 8:02:14 PM7/10/15
to django-s...@googlegroups.com
By default there is no initial Ajax request on page load when using django-selectable.

--
You received this message because you are subscribed to the Google Groups "django-selectable" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-selecta...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yoda

unread,
Jul 12, 2015, 7:55:26 AM7/12/15
to django-s...@googlegroups.com
That's good news, because it means I am doing something wrong and can learn how to do it right.

The selectable are used within an inline form which is part of a formset which is part of a form within a template that is included in other templates. The bottom level form includes the {{ form.media.js }} and therefore selectable.js is 400 times on the html page. Is this the reasons, why I get 400 ajax calls? Could you give me a hint how I can better manage the JavaScript code for django-selectable?

Thanks
yoda

Mark Lavin

unread,
Jul 12, 2015, 8:47:29 AM7/12/15
to django-s...@googlegroups.com
Again there is nothing in the JS which does an initial AJAX call so including the JS 400 times is not the cause of the calls but that is certainly not a good idea. If you need selectable on a page then you should include the CSS once in the head and the JS once at the end of the body.

The AJAX lookups are triggered on the input change but default requires at least 2 characters in the field before it will make the call. If your fields have an initial value in the over 2 characters and something on your page is causing them to gain/loss focus or trigger a change event, then you might see an initial call.

--
Reply all
Reply to author
Forward
0 new messages