dinbror / blazy

Hey, be lazy! bLazy.JS is a lightweight pure JavaScript script for lazy loading and multi-serving images. It's working in all modern browsers including IE7+.
http://dinbror.dk/blazy
MIT License
2.62k stars 355 forks source link

[Enchancement Request] Alter the target `src` attribute to load to <svg><image xlink:href="/images/photo.jpg"></svg> attribute #134

Open WhereJuly opened 7 years ago

WhereJuly commented 7 years ago

Hello Bjørn, thanks a lot for the great piece of functionality :)

Is it too difficult to make an src attribute changeanble via settings? I mean the use case for the .jpg images loaded into SVG <image> tag's xlink:href attribute.

Here is the use case I expoit: CSS Tricks Transparent JPG (With SVG).

This could be quite a good addition to blazy for advanced users I believe, especially in the case of mobile applications on 3G where the difference between png and jpg loading time can be considerable.

Something like this:

            var blazy = new Blazy({
                srcattribute: 'xlink:href' // default 'src'
            });

...and the markup:

            <svg>
                <image class="top-photo b-lazy" data-src="img/backgrounds/top-photo.jpg" xlink:href="img/backgrounds/top-photo.jpg" x="0" y="0">
            </svg>

Thanks again. Val