-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
36 lines (27 loc) · 1.83 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>SVGfall</title>
<script src="svgfall-v2.js"></script>
<style>
body { font-family: sans-serif }
img { max-width: 100% }
</style>
</head>
<body>
<h1>SVGfall: Fast fallback for SVG images.</h1>
<p>SVG background don't always cut it, sometimes a proper image is needed. With svgfall.js we detect SVG support failure and try to load an alternative asset, without messing with the CSS.</p>
<p>You just need to add <code>data-svgfall</code> data attribute to the <code>img</code> element</p>
<p>Library independent</p>
<h2>Speed first version</h2>
<p>This version of the polyfill, favours SVG capable browsers, letting you add SVG in <code><img></code> elements with no further complicated markup, and taking advantage of browser look ahead preloaders. The script only kicks in when svg support fails.</p>
<img src="external/imgs/Octocat.svg" data-svgfall alt="The Octocat, the Github mascot">
<noscript><img src="external/imgs/Octocat.png" alt="The Octocat, the Github mascot"></noscript>
<p>The script will try to look for an explicit alternative stored in the <code>data-fallback</code> data attribute, if it doesn't find the attribute, it will change the <code>.svg</code> extension in the <code>src</code> attribute and change it for <code>.png</code></p>
<img src="external/imgs/Octocat.svg" data-svgfall alt="The Octocat, the Github mascot" data-fallback="external/imgs/Octocat.jpg">
<noscript><img src="external/imgs/Octocat.png" alt="The Octocat, the Github mascot"></noscript>
<p>You can always use <code><noscript></code> to add an alternative for browsers with disabled JavaScript, in any case, it can always show the <code>alt</code> attribute.</p>
</body>
</html>