help - Slider script dies in Chrome, works great in Firefox
I implemented a slider along with input boxes that can work in tandem with the slider. When I started the records I was pulling in from the server was around 1000 and the slider worked well. Once the database table was updated and the amount increased to 7500, the slider has taken a dive in Chrome.
So if I just select say up to 1500 records from the database then no problems but once I go over that amount the slider becomes stuck and won't move without waiting a long time and even then, is difficult to move. Along with that the div takes too long for the update. I ran chrome performance testing and it seems 'update layer tree' is taking the most time. In Chrome JS profiler, it showed the each function taking a long time.
I tried changing the each to a regular for..in with no changes. I removed the input boxes with no changes. And I also took out all the other js scripts in my code so the slider stood alone. I wanted to see if anything else was effecting the slider. Again, this didn't seem to make a difference. As the title says Firefox runs this script fine.
Maybe someone has some suggestions for fixing it in Chrome or insight as to why FF handles it and Chrome does not. Side note, I'm running the app on an I5 mobile laptop with 8 gigs of memory.
Here is the script. Thanks in advance!
- jQuery("#amount1").change(function mySlider() {
- jQuery("#treble").slider('values',0,jQuery(this).val());
- });
- jQuery("#amount2").change(function mySlider() {
- jQuery("#treble").slider('values',1,jQuery(this).val());
- });
- function mySlider() {
- return jQuery('#treble').slider({
- range: true,
- min: 1,
- max: document.getElementById('albumCount').value,
- values: [1, 20]
- }, jQuery('#range').text("Choose a range"), {
- change: function changeRange(event, ui) {
- var sortPref = document.getElementById('searchprefform');
- var radioArray = [];
- var formData = new FormData(sortPref);
- for(var value of formData.values()) {
- radioArray.push(value);
- }
- var max, min;
- min = ui.values[0];
- max = ui.values[1];
- jQuery("#amount1").val(min);
- jQuery("#amount2").val(max);
- jQuery('#range').text(min + ' - ' + max);
- jQuery.ajax({
- url: '/range_from_catalog',
- type: 'get',
- data: {
- min: min,
- max: max,
- radioArray
- },
- dataType: 'json',
- success: function(response) {
- var albums;
- jQuery('#result').empty();
- albums = response;
- var i = 0
- jQuery.each(albums, function(key, value) {
- var sortPref;
- var fragment = document.createDocumentFragment();
- let li = document.createElement('li');
- li.className = 'list-group-item'
- li.id = `activelink${i}`
- let a = document.createElement('a')
- a.href = `/album_details/${encodeURI(value[0])}`
- a.id = `catalbumdet${i}`
- sortPref = `${value[1]} Date: ${value[2]}`
- a.appendChild(document.createTextNode(sortPref));
- li.appendChild(a)
- fragment.appendChild(li)
- jQuery('#result').append(jQuery(fragment));
- document.getElementById('result').className = 'scrolltest2'
- i++;
- return console.log;
- });
- }
- });
- }
- });
- };