jQuery Advanced SVG Fallback Plugin
A jQuery plugin for replace PNG
images to SVG
, if browser supports. Have a cache feature.
Getting Started
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="js/jquery.SVGfallback.min.js"></script>
<!-- If there are '/img/1.svg' - plugin will replace `src` attribute to SVG file -->
<img class="svg" src="/img/1.png">
<script>
$(document).ready(function() {
$('.svg').svgFallback({
allowExternalImages: false,
cachePrefix : 'svgCache_',
cacheEnabled : true,
storage : sessionStorage
});
});
</script>
Parameters
allowExternalImages
, default:false
;cachePrefix
, default:svgCache_
;cacheEnabled
, default:true
;storage
, default:sessionStorage
; Storage class object. By default you can setlocalStorage
(saves data for unlimited time) orsessionStorage
(remove data after browser closes). Also you can write your own storage class with methods:getItem(index)
,setItem(index, value)
andremoveItem(index)
License
Copyright (c) 2014 Nazarkin Roman Licensed under the MIT license.