Download the PHP package styletools/lazy without Composer

On this page you can find all versions of the php package styletools/lazy. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package lazy

Build Status Version npm version Latest Stable Version

$lazy Lazy Loader

A lightweight and high performance lazy loader and element-in-view callback based on Intersection Observer V2 with an efficient polyfill for old browsers.

$lazy can be configured using an async script element.

The script element accepts the following parameters:

Parameter Description Type
data-z Selector or config object. String
data-zz Multiple selector or config objects. Array
data-b Base path (URL rebasing) for HTML size compression. String

When using $async, $lazy can be used as a timing method with automated polyfill loading.

Documentation is available on pagespeed.pro/lazy.

Install via npm

Description

$lazy is designed as the ultimate lazy loader and element-in-view callback for frontend optimization (FEO). It provides state of the art features such as client-side Google .webp rewrite, the absolute best performance and the tiniest HTML footprint. $lazy supports all browsers including iPhone5 and IE9+. IE8 would be supported but isn't supported by Google's IntersectionObserver polyfill.

Advanced control of IntersectionObserver

$lazy provides full control of the IntersectionObserver and supports the latest features.

To save size, the configuration can be provided as an array.

$lazy returns a DOM NodeList with elements watched by the observer.

Security

$lazy supports a strict Content-Security-Policy and can be controlled by a async HTML script tag.

Multiple configurations are supported via the attribute data-zz. The attributes accepts a JSON array with configurations.

Compressed srcset

$lazy enables to compress srcset to save HTML document size using the attribute data-z.

Advanced in-view and out-of-view callback

$lazy enables to make full use of the IntersectionObserver for any purpose and supports a simple in-view callback, an out-of-view callback or a custom IntersectionObserver callback.

By returning false from a custom inview callback, the observer will not be removed and will trigger the callback again when the element moves in or out of view. The third parameter is a boolean with the in-view status.

For advanced usage, the inview argument accepts an array with 3 index positions:

  1. inview: a function to call when the element moves into view.
  2. out-of-view a function to call when the element moves out of view
  3. after_inview a function to call when using the default inview-method (the image resolver) after src and srcset have been rewritten.

When out-of-view is null, the inview method is used as the out-of-view callback.

The after_inview callback enables to easily extend resolved images by the default image resolver.

Custom IntersectionObserver callback

The third argument enables to manually define the IntersectionObserver callback which makes it possible to use $lazy for easy access to the functionality provided by IntersectionObserver.

Events

$lazy provides an extension that watches for mouseover, click and the custom z event to fire the in-view callback manually. This feature ensures that images are resolved in the case of issues with the IntersectionObserver polyfill and it enables to manually trigger the callback, for example before printing.

It is possible to manually define events to watch using the configuration parameter events or the array index 4.

Manually resolve images

$lazy enables to manually resolve images using the default image resolver by providing 1 as the in-view callback.

Client-side .webp rewrite

$lazy provides an extension to automatically rewrite images to .webp in browsers that support Google's WebP image format. The solution prevents a server-side redirect which improves performance.

The solution is fail safe and uses <img onerror> as a fallback to the original image when the .webp image is 404 or fails to load.

It is possible to manually disable the .webp rewrite for an image by defining the HTML attribute data-webp="no" or by using the $lazy configuration parameter webp or array index 3.

$lazybg supports .webp rewrites as well.

$lazybg lazy loading of background-image

$lazy provides a unique innovation to lazy load background-image in stylesheets using CSS Variables with a fallback for old browsers.

There are four options to resolve images:

  1. manually define images via :root {} within the stylesheet
  2. base64 encode image URLs
  3. provide a JSON source list as resolver
  4. provide a javascript function as resolver

Note: CSS variables are limited to DOMString. When using inline base64 encoding, the following characters need to be replaced in the encoded value:

/:

=:

Polyfill

$lazy provides support for Google's IntersectionObserver polyfill with 0% performance hit for modern browsers.

When using the polyfill extension, $lazy checks for the parameter window.$lazypoly when IntersectionObserver is not supported by the browser.

When window.$lazypoly is defined as a function, $lazy will fire it and expect a .then method to be resolved when the polyfill is loaded.

When window.$lazypoly is defined as a string, the string is passed to $async.js that could load anything.

$lazy as a timing method in $async

$lazy and the polyfill can be efficienty loaded using $async and it's just-in-time timing method. $lazy then becomes available as a timing method within $async which enables to load stylesheets and scripts using the IntersectionObserver.

$async enables to load the $lazy script and its optional polyfill from localStorage for exceptional speed.

Note: to use $lazy as a timing method in $async you need to set the ref of the lazy.js script to $z.

When including the $lazy script inline, the data-poly attribute enables to define a string to pass to $async to load a polyfill.


All versions of lazy with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package styletools/lazy contains the following files

Loading the files please wait ....