Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mudkipme/mediawiki-lazyload
An extension to delay loading of images on MediaWiki pages.
https://github.com/mudkipme/mediawiki-lazyload
lazyload mediawiki mediawiki-extension
Last synced: about 1 month ago
JSON representation
An extension to delay loading of images on MediaWiki pages.
- Host: GitHub
- URL: https://github.com/mudkipme/mediawiki-lazyload
- Owner: mudkipme
- License: mit
- Created: 2014-06-26T13:15:34.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-11-22T19:42:04.000Z (about 2 years ago)
- Last Synced: 2024-04-15T01:10:49.342Z (8 months ago)
- Topics: lazyload, mediawiki, mediawiki-extension
- Language: JavaScript
- Size: 17.6 KB
- Stars: 11
- Watchers: 4
- Forks: 7
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
MediaWiki Lazyload Extension
============================An extension to delay loading of images on MediaWiki pages.
## Requirements
Lazyload extension requires MediaWiki 1.25 or higher.
## Installation
To install the extension, place the entire `Lazyload` directory within your
MediaWiki `extensions` directory, then add the following line to your
`LocalSettings.php` file:```php
wfLoadExtension( 'Lazyload' );
```If you are using the [APNG extension](https://github.com/mudkipme/mediawiki-apng) on your wiki, please upgrade it to 0.2.0 or higher.
## Configuration
Lazyload extension supports dynamically replace image hosts or disable HiDPI support for certain cases in [JavaScript](https://www.mediawiki.org/wiki/Manual:Interface/JavaScript). This is particularly useful when your wiki wants to use multiple CDNs for various conditions.
```javascript
mw.config.set('Lazyload.imageHost', YOUR_IMAGE_HOST);
mw.config.set('Lazyload.disableHidpi', true);
```A use case in [52Poké Wiki](https://wiki.52poke.com/) is setting the image host to CDN only for non-logged in users, and another CDN domain backed by [malasada](https://github.com/mudkipme/malasada) for browsers supporting WebP to minimize traffic cost.
```javascript
(function() {
if (mw.config.get('wgUserName')) {
return;
}
mw.config.set('Lazyload.imageHost', '//s0.52poke.wiki');
mw.config.set('Lazyload.disableHidpi', true);function testWebP(callback) {
var webP = new Image();
webP.onload = webP.onerror = function () {
callback(webP.height === 2);
};
webP.src = 'data:image/webp;base64,UklGRjoAAABXRUJQVlA4IC4AAACyAgCdASoCAAIALmk0mk0iIiIiIgBoSygABc6WWgAA/veff/0PP8bA//LwYAAA';
}testWebP(function (supported) {
if (supported) {
mw.config.set('Lazyload.imageHost', '//s1.52poke.wiki');
}
});
})();
```## License
[MIT](LICENSE)