jQuery UI datepicker performance on select -


i've got instance of jquery ui datepicker here:

https://app.shvitz.com.au/en/listings/11-yoga-in-the-park

wait couple of seconds load on right side of page.

i'm experiencing strange performance issues when selecting dates. can view source in calendar.js, relevant part:

function onselect(date, instance) {     var mdate = moment(date, "dd-mm-yyyy");     var $timeslots = rendertimeslots(mdate);     $container.children('.timeslots-container').remove();     $container.append($timeslots); }  function rendertimeslots(date) {     if (!date) date = moment(calendar.datepicker('getdate').gettime());      var times = availabilities.filter(function (a) {         return moment(a.start_time).startof('day').issame(date.startof('day'));     });      function availtoprice(a) {         function getprice(a) {             if (!api.getshared()) return 66;              var left = a.capacity - a.bookings;             switch (left) {                 case 1:                     return 20;                 case 2:                     return 25;                 case 3:                     return 35;                 case 4:                     return 35;             }         }          var ret = '$' + (getprice(a) * (a.duration / 60)).tofixed(2);         var people = a.bookings + ' people';         if (a.bookings == 0) {             people = 'empty';         } else if (a.bookings == 1) {            people = '1 person';         }         return ret + ' - ' + people;     }      var timeslots = times.map(function (t) {         return $('<div class="clearfix switch-field"><input id="' + t.start_time + '" name="calendar-timeslots" type="radio" value="' + t.start_time + '"/> <label for="' + t.start_time + '" style="margin:0" class="btn btn-success calendar-timeslot">' + moment(t.start_time).format('hh:mm a') + '(' + availtoprice(t) + ')' +             '</label></div>');     });     if (onchange !== null) {         timeslots.foreach(function ($t) {             $t.children('input').click(function () {                 onchange({                     'shared': api.getshared(),                     'time': api.gettime()                 });             });         });     }     var $cont = $('<div class="timeslots-container"></div>');     $cont.append(timeslots);     return $cont; } 

when click on date you'll notice delay before changes colour blue , timeslots rendered below. estimate delay @ least few hundred milliseconds. however, when use console.time measure time taken in onselect function it's typically around 20ms, , worst saw 60ms. additional delay coming from, , how can fix it?

jquery ui has delay proces, if want optimize ui, should use html5 no jquery.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -