Frage

let's say I got 10 images and 7 of this images are excluded(customer don't see them) or I got 3 images with none of them are excluded. Would there be any difference in the loading time?

War es hilfreich?

Lösung

What do you consider 'loading time'? Processing time on server side (PHP) to get images? Rendering time on client for DOM? Loading of assets from client, per image?

Obviously, if you do not output the hidden images to the DOM, that would decrease rendering, and loading time. Since normal procedure for magento is to not place those images in the DOM (so they are not rendered), there will be no difference in client side 'loading time'

In either usage case, you will only have 3 images for the client to load/render.

You can have a slight (very slight) performance increase on the server side, if you have no hidden images. Frankly, this will be so insignificant, that it is really nothing to worry about. It may only be an issue if you have hundreds of images, of which only a few is visible.

You can see this in the core routine Mage_Catalog_Model_Product ::getMediaGalleryImages

/**
     * Retrive media gallery images
     *
     * @return Varien_Data_Collection
     */
    public function getMediaGalleryImages()
    {
        if(!$this->hasData('media_gallery_images') && is_array($this->getMediaGallery('images'))) {
            $images = new Varien_Data_Collection();
            foreach ($this->getMediaGallery('images') as $image) {
                if ($image['disabled']) {
                    continue;
                }
                $image['url'] = $this->getMediaConfig()->getMediaUrl($image['file']);
                $image['id'] = isset($image['value_id']) ? $image['value_id'] : null;
                $image['path'] = $this->getMediaConfig()->getMediaPath($image['file']);
                $images->addItem(new Varien_Object($image));
            }
            $this->setData('media_gallery_images', $images);
        }

        return $this->getData('media_gallery_images');
    }

You can clearly see here that the hidden images are still loaded, when the product is loaded, and a conditional excludes them from the output to your frontend layer.

If this is an issue, and you are trying to squeeze out some more performance, you can potentially dig into the call $this->getMediaGallery('images'), and (at the source) exclude the hidden images.

Additionally, any block/fpc caching would negate this on subsequent page loads.

Hope that helps.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit magento.stackexchange
scroll top