Integration of lazysizes, a lightweight lazy loader, into Plone.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/collective Code cleanup (#74) Oct 17, 2018
.travis.yml Avoid issues with Coveralls Oct 17, 2018



Life, the Universe, and Everything

This package integrates lazysizes, a lightweight lazy loader, into Plone.

lazysizes is a fast, SEO-friendly and self-initializing lazyloader for images (including responsive images picture/srcset), iframes, scripts/widgets and much more. It also prioritizes resources by differentiating between crucial in view and near view elements to make perceived performance even faster.

By using this package you can expect reductions of up to 80% in load time, 75% in page size and 50% in number of requests.

Mostly Harmless

These are some sites using collective.lazysizes:

As long as we have tested, lazysizes seems not to interfere with image indexing made by crawlers like Googlebot.

Got an idea? Found a bug? Let us know by opening a support ticket.

Don't Panic


To enable this package in a buildout-based installation:

  1. Edit your buildout.cfg and add collective.lazysizes to the list of eggs to install:
eggs =

After updating the configuration you need to run ''bin/buildout'', which will take care of updating your system.

Go to the 'Site Setup' page in a Plone site and click on the 'Add-ons' link.

Check the box next to collective.lazysizes and click the 'Activate' button.

How does it work

This package adds a transformer to the transform chain to integrate lazysizes into Plone.

The transformer looks for all the <img>, <iframe> and <blockquote> tags inside the content and does the following:

  • appends a lazyload class
  • if the tag is an <img>, transforms the src attribute into a data-src and uses a gray square in its place to maintain valid HTML code (this placeholder is loaded using the data URI scheme to avoid a new request to the server)
  • if the tag is an <iframe>, transforms the src attribute into a data-src
  • if the tag is a <blockquote> containing a tweet, it adds a data-twitter attribute and removes the <script> tag associated with the Twitter widget to avoid a useless request

These transforms can be applied to all users or only to anonymous.

Look Ma! No Resource Registries

This add-on uses a very opinionated approach on how to handle static resources in Plone. We just deprecated resource registries in favor of a simpler approach: a viewlet in plone.htmlhead. This simplifies maintainance among multiple Plone versions and avoids bundling of unrelated resources.


We use webpack to process static resources on this package. Webpack processes SCSS and JS files, minifies the resulting CSS and JS, and optimizes all images.

To contribute, you should start the instance in one shell and start webpack watcher on another with the following command:

$ bin/watch-lazysizes

Then go to webpack/app folder and edit SCSS and JS files; webpack watcher will automatically create the final resources in the right place.

There are also other commands added to handle more complex scenarios.

The following command will set the buildout node installation in the system PATH, this way you can use webpack as described on their documentation.

$ bin/env-lazysizes

The following command generates JS and CSS without the minify step (it can be used to check the code being generated in a human readable way).

$ bin/debug-lazysizes

The following command rebuilds static files and exit (insted of keep watching the changes):

$ bin/build-lazysizes