The progressive image loading library for great good!

Overview

AntiModerate

The progressive image loading library for great good!


Reduce loading time of page to less than a second on slow connections by loading and rendering nicely blurred micro images on the page while loading full sized images in background which replace as they finish.

Has a nice blur effect thanks to StackBlur so you have a good looking page while it is loading.

Library is space optimized, with gzip it is less than 2kb.

Example

##Installation

You can install this using bower or npm:

  bower install antimoderate
  npm install antimoderate --save

##Example

<img src="1.jpg" id="picture" style="width:200px; height:200px;" data-antimoderate-idata="data:image/jpg;base64, /9j/4AAQSkZJRgABAQEASABIAAD//gATQ3JlYXRlZCB3aXRoIEdJTVD/2wBDAAoHBwgHBgoICAgLCgoLDhgQDg0NDh0VFhEYIx8lJCIfIiEmKzcvJik0KSEiMEExNDk7Pj4+JS5ESUM8SDc9Pjv/2wBDAQoLCw4NDhwQEBw7KCIoOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozv/wgARCAAlACgDAREAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAwQCBQYB/8QAGAEBAQEBAQAAAAAAAAAAAAAAAAEDAgT/2gAMAwEAAhADEAAAAeyqgi0iYKg56Gw9ZfX4JRCq+VfjV3TGxgdZhFKcNJyNWUpYOajl/8QAHxAAAgICAgMBAAAAAAAAAAAAAQIAAwQTEjERISQj/9oACAEBAAEFApdZrVbrEMHcYeLba9og7mXbqV8rYtF/KDuZLfWCFisDMdi1XGZdf1mv1UnrFH4//8QAHREAAgIBBQAAAAAAAAAAAAAAAQMAESACITAxMv/aAAgBAwEBPwHJfqMXfeANGMcdW3L/AP/EABsRAAEFAQEAAAAAAAAAAAAAAAECEBEgMQAD/9oACAECAQE/AaHGXnJXGMcdPnBljlTlT3//xAAfEAABAwQDAQAAAAAAAAAAAAABAAIxEBEhQRITgSD/2gAIAQEABj8CWJMIdkHdBRrrD1C+vhuLklcW+ri+avvrAq0mj8qVMJq//8QAIhAAAgIBBAEFAAAAAAAAAAAAAAERITFBUWFxkbHB0eHx/9oACAEBAAE/IYI5QxhRpOOFiQvmILCNOAmRSllbCQleyBSOkLwNsFFSdlOjS9xKdkD062BtQ2+BNCcmRf7Ox2uHjg/IJ29AqZw/c//aAAwDAQACAAMAAAAQEOE8lCmMc38Gf//EABsRAQEBAAIDAAAAAAAAAAAAAAERABAgITGx/9oACAEDAQE/ENdE99HAzAa5PnSA4GPBryMeTt//xAAcEQACAwEAAwAAAAAAAAAAAAAAARARMSEgQbH/2gAIAQIBAT8QKLTyNI7Lnr2+xpDVqhdjRo0irU7eCOk0f//EACMQAQACAQIGAwEAAAAAAAAAAAEAESExQRBRYXGRsYGh8OH/2gAIAQEAAT8QY1kLJt1lp1AlBtacDwD3w6OoWqqKZIsZhNz5cHxL3DohlQbSiDWOaXAsbyekoCxhs/3PFvcIXeoGOCjP2sHK5vNc+ZaAjvRMyjwvOqX9Q/BMZpfgOs06dPzWbBYd0W5aw07p/9k=">
<script src="antimoderate.js"></script>
<script>
    var img = document.getElementById('picture');

    AntiModerate.process(img, img.getAttribute("data-antimoderate-idata"));
</script>

##License

###AntiModerate

Copyright (c) 2016 Jett LaRue

Do whatever with it.

###StackBlur Algorithm

Copyright (c) 2010 Mario Klingemann

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.
Comments
  • support (plugin)

    support (plugin)

    Hi.

    the plugin looks impressive, but I would like to see a more concrete example on the operation. I don't understand how to use this plugin. When the base64 image is shown and when is hidden? whom control this status? me or this plugin does that?

    opened by alejokum122 7
  • Two Requests

    Two Requests

    This is funny, there is 2 requests for the base64 encoded image : one for jpeg & one for png.

    image

    Where does this come ?

    By the way, your lib is working great, thanks :)

    opened by Shuunen 4
  • better readme / usage guide

    better readme / usage guide

    thanks for this idea. what is the best way to populate the data variables for each image in PHP? the readme has no explanation of this aspect of this project and so updating the readme to include full instructions would be a great help.

    opened by propertunist 3
  • Large image loads, small image(very briefly), then large image again

    Large image loads, small image(very briefly), then large image again

    Hi,

    Awesome plugin you have hear. Am really loving it. But i have this problem.

    When i load the page (force reload without cache), this is what i experience

    1. It loads the large image for some few seconds
    2. It then shows the tiny image (for a fraction of a second), very fast
    3. Then, it finally shows the large image again.

    This twitch causes an undesired effect to the users and its not good for my website.

    Trying to follow up with network elements on my chrome, i noticed the large image is loaded first before the smaller image, i don't know if am doing something wrong.

    My code is structured like so

    // Load css stylesheets
    ...
    // Render image
    <img 
    	class="antimoderate-img img-fluid" 
    	src="{{ asset($image->img_path) }}" 
    	data-antimoderate-idata="{{ asset($image->thumbnail_img) }}" 
    	alt="{{$a_listing->headline}}" 
    	title="{{ $a_listing->headline }}" 
    	>
    ...
    // Load jquery and other plugins then load antimoderate plugin
    // in one of the custom js files, i call the antimoderate plugin like so 
    if (AntiModerate !== undefined && $ !== undefined) {
        var antimoderateImgs = document.getElementsByClassName('antimoderate-img');
        for (var i = 0; i < antimoderateImgs.length; i++) {
            var aImg = antimoderateImgs[i];
            AntiModerate.process(aImg, aImg.getAttribute("data-antimoderate-idata"));
        }
    }else{
        $().toastmessage('showToast', {
            text:       'Smooth image loading is not loaded/supported by your browser', 
            stayTime:   10000,
            type:       'warning',
        });
    }
    

    Screenshot: Big img, fast small img then big img

    opened by bosz 0
  • Info about the license unclear

    Info about the license unclear

    Hi :)

    I have a short question about the correct license of your repo. In the bower.json it's listed with MIT bit in your readme it looks like CC-0 or public domain ("Do whatever with it"). I wanted to add your repo to a CDN and want to add the correct license there.

    Thank!

    opened by programmiri 1
  • Expected behavior happening in reverse.

    Expected behavior happening in reverse.

    So, Antimoderate seems to be working insofar that it "knows" about my tiny image and my regular thumbnail.

    To be clear, my problem is that I get the large image first and then it is replaced by the small image.

    Am I doing something wrong?

    Thanks.

    Here is my HTML:

    <img src="image.php?f=thumbs/clock_thumb.png" class="center-light thumbnail" style="width:200px; height:200px;" data-antimoderate-idata="data: image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAAA1CAYAAAC+2+58AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4AQTFgEb5mnI/AAABM5JREFUeNrtnNtu3DYQhr8hKXF33Tq5aNGLPkUu8gJBXjvv0yBt4LjeXZ3I6YVNmauDj2mctBxAMKChfg3nH45O/1pUVSn2YmZKCgoBhYBihYBCQLFCQCGg2Lc3NwxDycJLEvDhw4eShe+BgPJA/O1NVZG3b9/qEgEiMhv8o/qXiutr4Kcxqvro49M+pxpBYequ6xpjrq/RXdcRYzzxW2vx3gMQQqBpmhNg7z273Q6Atm05HA4nQXnvsdYC0DTNDN85x2azQUTo+57j8Tj6oipnZ2fXfmC/39M0zQl+Xdcjftu2hBBO8KuqYrvdjvPL8VWV3W43+g+HA8fjccQXETZ+w6vzVyhK0zRcfLk4Of78/HzM4eXlJV3XzUhQVVyUDQiAItpBNmjK4lIVichscsmXCLzr2Pv80zFGhEqEjbV4YxhW4rwP/65zTONf9Huwrw1ERXRe7el4a+1qHMYYXKu/ImIQIhV/IPR3LmVjzMhkjHE1ySIyjkt/83334avqIn7lHK9j5GdrQZWLmziWzpkSkXwJ7yHx53HP8A3o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BPzv7B9y+cxPbcg6AgAAAABJRU5ErkJggg==" antimoderate>
    

    Here is my JS:

     if (AntiModerate !== undefined && $ !== undefined) {
                        console.log("AntiModerate is ready to blur your images!");
                        //
                        $( "[antimoderate]" ).each(function( index, obj ) {
                            AntiModerate.process(obj, obj.getAttribute("data-antimoderate-idata"));
                        });
                    }
    
    hacktoberfest 
    opened by paxperscientiam 10
  • img srcset support (question)

    img srcset support (question)

    Hi.

    This is awesome. Thanks so much for putting this together.

    Does it support the srcset attribute of the img tag? The reason I ask is I'm putting together a WordPress plugin for this library and WP automagically creates a srcset list when you upload an image.

    opened by richardtape 1
Owner
Jett LaRue
Jett LaRue
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Hackathon for Social Good 2022 and use your superpowers to create a solution for the social good.

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

Laura Diaz 3 Jun 27, 2022
A Very Good Documentation Site created by the Very Good Ventures Team 🦄

Very Good Docs Site Developed with ?? by Very Good Ventures ?? A Very Good Docs Site created by the Very Good Ventures Team. Generated by the Very Goo

Very Good Open Source 8 Nov 2, 2022
Fast and lightweight dependency-free vanilla JavaScript polyfill for native lazy loading / the awesome loading='lazy'-attribute.

loading="lazy" attribute polyfill Fast and lightweight vanilla JavaScript polyfill for native lazy loading, meaning the behaviour to load elements rig

Maximilian Franzke 571 Dec 30, 2022
optimize image & upload file to cloud as image bed with tiny image automic.

Rush! 图片压缩 & 直传图床工具 这是一个兴趣使然的项目, 希望 Rush! 能让这个世界的网络资源浪费减少一点点 下载 Downloads 获取最新发行版 功能 Features 拖拽批量压缩图片, 支持格式 jpg/png/gif Drop to optimize, jpg/png/gif

{ Chao } 3 Nov 12, 2022
A jQuery plugin that lets you attach callbacks to useful image loading events.

waitForImages Copyright (c) 2011-2018 Alexander Dickson @alexdickson Licensed under the MIT licenses. http://alexanderdickson.com Donate! Overview Pro

Alexander Dickson 1.3k Dec 28, 2022
BttrLazyLoading is a Jquery plugin that allows your web application to defer image loading until images are scrolled to but not only

BttrLazyLoading.js BttrLazyLoading is a Jquery plugin that allows your web application to defer image loading until images are scrolled to but not onl

Julien Renaux 410 Dec 14, 2022
A Javascript library that discourages and prevents image theft/download by preventing client ability to retrieve the image.

ProtectImage.js ProtectImage.js is a Javascript library that helps prevent image theft by disabling traditional user interactions to download/copy ima

null 4 Aug 18, 2022
Simple JavaScript Library to add parallax image to background-image

Backpax Simple JavaScript Library to add parallax image to background-image Install $ npm install backpax --save Demo Demo page is here Usage If you

appleple 13 Oct 12, 2022
Fallback JS - JavaScript library for dynamically loading CSS and JS files

Fallback JS - JavaScript library for dynamically loading CSS and JS files. Also provides the ability to load multiple files from a CDN with multiple fallback options and shimming!

Dolox Inc. 311 Nov 13, 2022
A modern lazy loading library for images.

Layzr.js A modern lazy loading library for images. Demo Page Getting Started Follow these steps: Install Setup Images Instantiate Review Options Revie

Michael Cavalea 5.6k Dec 25, 2022
Fnon is a client-side JavaScript library for models, loading indicators, notifications, and alerts which makes your web projects much better.

???????? Fnon is the name of my late mother, It's an Arabic word which means Art, I created this library in honor of her name. Fnon is a client-side J

Adel N Al-Awdy 5 Sep 11, 2022
A concise collection of classes for PHP, Python, JavaScript and Ruby to calculate great circle distance, bearing, and destination from geographic coordinates

GreatCircle A set of three functions, useful in geographical calculations of different sorts. Available for PHP, Python, Javascript and Ruby. Live dem

null 72 Sep 30, 2022
A Meme generator website where you can change and customize images to create great memes😎.

App Screenshot: Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory,

Harsh Jain 7 Dec 21, 2022
Solidity starter combining foundry and hardhat because both are great and I can't live without either...

Combination Pizza Hut & Taco Bell Foundry && HardHat starter template. Motivation I like them both. With this set-up we get: Unit tests written in sol

Cache Monet 32 Aug 23, 2022
A great result management solution for schools, hospital, academy and other. If you are a php developer, contribute to this respository for more advancement of the project.

result-management-pro A great result management system for schools, hospital, academy and more. Contributions Willing to add more features to this gre

Adeleye Ayodeji 8 Jun 17, 2022