Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including cordova-plugin-sdwebimage with all npm packages installed. Try it out:

cordova-plugin-sdwebimage lists no main file and has no index.js, so it can't be directly required. If this is a mistake, please let us know. It may however contain internal files that you can require manually:

// require("cordova-plugin-sdwebimage/[??]")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

cordova-plugin-sdwebimage v1.0.0

Optimise image loading in your cordova app

cordova-plugin-sdwebimage

Use SDWebImage + WebViewProxy to cache images in your cordova app.

See benchmarks at https://github.com/revolunet/cordova-plugin-sdwebimage-test

Installation

Install the plugin :

cordova plugin add --save https://github.com/revolunet/cordova-plugin-sdwebimage.git

Usage

// get image as base64
cordova.plugins.SDWebImage.getImage(url, function(base64) {
  console.log(base64);
});

// prefetch some urls in cached
cordova.plugins.SDWebImage.prefetchURLs(urls, function() {
  // all done
});

// get info about objects in SDImageCache
cordova.plugins.SDWebImage.getCacheInfo(function(data) {
  console.log(data);
});

// Clear SDImageCache
cordova.plugins.SDWebImage.clearCache(function() {
  // all done
});

Also adds a proxy that intercepts calls to http://proxy/http://path/to/image and return cached version of http://path/to/image and force 1 year expiration.

Todo :

Licence MIT

Code distributed under MIT licence. Contributions welcome.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free