Skip to content
Browse files

No requests to the server

  • Loading branch information...
1 parent 830109c commit 812c5e9c7ea62554bfb3b64cf2b962a09da25f35 Glavan Dumitru committed Mar 8, 2011
Showing with 10 additions and 5 deletions.
  1. +1 −1 assets/jquery.imageCache.js
  2. +9 −4 demo.html
View
2 assets/jquery.imageCache.js
@@ -29,7 +29,7 @@
$(document).ready(function () {
$(self).each(function (i, img) {
- var src = $(img).attr('src');
+ var src = $(img).attr('src') || $(img).attr('data-src');
if (localStorage) {
var localSrc = localStorage[src];
if (localSrc) {
View
13 demo.html
@@ -10,15 +10,20 @@
</head>
<body>
- <h1>jQuery Image Cache plugin</h1>
+ <h1>jQuery Image Cache plugin</h1>
- <p>Images are kept in browser's Local Storage!</p>
+ <p>Images are kept in browser's Local Storage! But, sometimes they do a request to the server to check if the image is not updated when you keep the SRC attribute.</p>
<ul>
<li><img src="assets/test-image-1.jpg" class="imageCache" /></li>
<li><img src="assets/test-image-2.jpg" class="imageCache" /></li>
- <li><img src="assets/test-image-4.jpg" class="imageCache" /></li>
- <li><img src="assets/test-image-5.jpg" class="imageCache" /></li>
+ </ul>
+
+ <p>Images are kept in browser's Local Storage! No requests to the server are done because the image URL is not stored in the SRC attribute anymore but in data-src.</p>
+
+ <ul>
+ <li><img src="" data-src="assets/test-image-4.jpg" class="imageCache" /></li>
+ <li><img src="" data-src="assets/test-image-5.jpg" class="imageCache" /></li>
</ul>
<script type="text/javascript">

0 comments on commit 812c5e9

Please sign in to comment.
Something went wrong with that request. Please try again.