diff --git a/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js b/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js index 59fc40a1edc91..3aa5105885f5d 100644 --- a/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js +++ b/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js @@ -7,12 +7,11 @@ define([ 'jquery', 'underscore', 'mage/template', - 'mage/gallery/preloadImages', 'priceUtils', 'priceBox', 'jquery/ui', 'jquery/jquery.parsequery' -], function ($, _, mageTemplate, preloadImages) { +], function ($, _, mageTemplate) { 'use strict'; $.widget('mage.configurable', { @@ -40,10 +39,6 @@ define([ // Initial setting of various option values this._initializeOptions(); - //Preload all gallery images - this._preloadImages(); - this._preloadOptionalImages(); - // Override defaults with URL query parameters and/or inputs values this._overrideDefaults(); @@ -93,43 +88,6 @@ define([ }); }, - /** - * Preloads default configuration images. - * @private - */ - _preloadImages: function () { - var options = this.options, - fullImagesList = [], - imagesList = []; - - _.each(options.mediaGalleryInitial, function (item) { - imagesList.push(item.img); - fullImagesList.push(item.full); - }); - preloadImages(imagesList); - preloadImages(fullImagesList); - }, - - /** - * Preloads optional configuration images. - * @private - */ - _preloadOptionalImages: function () { - var options = this.options; - - _.each(options.spConfig.images, function (array) { - var fullImagesList = [], - imagesList = []; - - _.each(array, function (item) { - imagesList.push(item.img); - fullImagesList.push(item.full); - }); - preloadImages(imagesList); - preloadImages(fullImagesList); - }); - }, - /** * Override default options values settings with either URL query parameters or * initialized inputs values. diff --git a/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js b/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js index b6da3a8642bd4..daca8e5bdafac 100644 --- a/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js +++ b/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js @@ -6,9 +6,8 @@ define([ 'jquery', 'underscore', - 'mage/gallery/preloadImages', 'jquery/ui' -], function ($, _, preloadImages) { +], function ($, _) { 'use strict'; /** @@ -272,24 +271,6 @@ define([ 'img': $main.find('.product-image-photo').attr('src') }]; } - this._preloadSwatchesImages(); - }, - - /** - * Preloads optional configuration images. - * @private - */ - _preloadSwatchesImages: function () { - var options = this.options; - - _.each(options.jsonConfig.images, function (array) { - var imagesList = []; - - _.each(array, function (item) { - imagesList.push(item.img); - }); - preloadImages(imagesList); - }); }, /** diff --git a/lib/web/mage/gallery/preloadImages.js b/lib/web/mage/gallery/preloadImages.js deleted file mode 100644 index 2c5ef6c00be5c..0000000000000 --- a/lib/web/mage/gallery/preloadImages.js +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ - -define([], function () { - 'use strict'; - - /** - * Loads images into browser's cash. - * @param {Array } array - List of sources of images. - */ - var preloadImages = function (array) { - var list, - i, - img, - addToList; - - /** - * Add image source to the list of loaded images - * @param {Object} scope - this object - */ - addToList = function (scope) { - var index = list.indexOf(scope); - - if (index !== -1) { - list.splice(index, 1); - } - }; - - if (!preloadImages.list) { - preloadImages.list = []; - } - list = preloadImages.list; - - for (i = 0; i < array.length; i++) { - img = new Image(); - - img.onload = addToList(this); - - list.push(img); - img.src = array[i]; - } - }; - - return preloadImages; - -});