Skip to content

Commit 3d9cd75

Browse files
MAGETWO-67010: [Performance] Swatches real server side optimization
1 parent 3c41b64 commit 3d9cd75

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ define([
276276
*/
277277
getProduct: function () {
278278
var products = this._CalcProducts();
279+
279280
return _.isArray(products) ? products[0] : null;
280281
},
281282

@@ -285,7 +286,7 @@ define([
285286
_init: function () {
286287
// creates debounced variant of _LoadProductMedia()
287288
// to use it in events handlers instead of _LoadProductMedia()
288-
this._debouncedLoadProductMedia = _.debounce(this._LoadProductMedia.bind(this), 1000);
289+
this._debouncedLoadProductMedia = _.debounce(this._LoadProductMedia.bind(this), 500);
289290

290291
if (this.options.jsonConfig !== '' && this.options.jsonSwatchConfig !== '') {
291292
// store unsorted attributes
@@ -945,8 +946,8 @@ define([
945946
$widget.options.mediaCache[mediaCacheKey] = data;
946947
}
947948
$widget._ProductMediaCallback($this, data, productData.isInProductView);
948-
setTimeout(function() {
949-
$widget._DisableProductMediaLoader($this)
949+
setTimeout(function () {
950+
$widget._DisableProductMediaLoader($this);
950951
}, 300);
951952
};
952953

@@ -1209,8 +1210,10 @@ define([
12091210
* @private
12101211
*/
12111212
_setPreSelectedGallery: function () {
1213+
var mediaCallData;
1214+
12121215
if (this.options.jsonConfig.preSelectedGallery) {
1213-
var mediaCallData = {
1216+
mediaCallData = {
12141217
'product_id': this.getProduct()
12151218
};
12161219

0 commit comments

Comments
 (0)