Skip to content
This repository has been archived by the owner on Jul 10, 2019. It is now read-only.
/ scroogify Public archive

Simpler responsive images for your mobile web site/app. No markup changes. No maintenance headaches.

Notifications You must be signed in to change notification settings

kaizau/scroogify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scroogify your responsive images!

(Version 0.0.1.pre)

Scroogify is a plug-and-play script for sending screen-optimized images to mobile browsers. A 640x960 phone doesn't need a full 2000x1600 image. Instead, Scroogify sends it a scaled-down copy — in most cases, resized exactly to the rendered size on the screen. No wasted pixels and no browser image-resizing.

Why another responsive image library? Other options require changes to your markup, cater towards PHP and Apache setups, and add major development and maintenance overhead. Scroogify's minimum-viable setup is a single step:

<script src="/javascripts/scroogify.min.js"></script>

TL;DR

  • Vanilla javascript, works with any library
  • Simple setup: just add the script to your <head>
  • Does not require markup changes, fails gracefully without JS
  • Uses Sencha Src or your own self-hosted scroogify-node instance for image resizing
  • Configurable via data-attributes on the script tag
  • NOTE: Does not stop browsers from prefetching large image assets. I'm still experimenting with solutions for this.

How it works

Scroogify only executes on screens smaller than a configurable threshold. On execution, it modifies all image src attributes to use an image-resizing service. If the image is stretched by CSS or HTML height and width attributes, Scroogify detects this and requests an image that fits the rendered size exactly.

Configuration

(Default values shown)

data-threshold="1280"

The pixel threshold above which Scroogify does not execute.

data-path="http://src.sencha.io/{{width}}/{{url}}"

The URI to which images are rewritten. Works as long as {{width}} and {{url}} are present.

data-placeholder="data:image/gif;base64,………"

The path to a 1px placeholder gif/png. Defaults to a data-URI, but you may see a performance boost by using an actual gif, due to browser caching.

TODO

  • Speed tests
  • Simple recipe to disable prefetching?
  • Heavy browser testing (not just webkit :P)
  • Optimize for speed
  • Bandwidth detection? (a la foresight.js)

License

Copyright (c) 2012 Yifei Zhang (http://yifei.co)

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Simpler responsive images for your mobile web site/app. No markup changes. No maintenance headaches.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published