Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Releases: shinsenter/defer.php

[Hotfix] Escape node value

08 Apr 06:37
b730437
Compare
Choose a tag to compare

Escape content before changing node value

Bug fixes

07 Apr 14:35
c3b381a
Compare
Choose a tag to compare

Bug fixes:

  • Improved HTML minification
  • Improved lazy loading ALL script tags
  • Improved img optimizations
  • Added parameter nodefer
  • Do not create noscript tag if already exists
  • Updated composer.json requirement

Hot fixes

30 Mar 16:29
e36fc56
Compare
Choose a tag to compare

Hot fixes:

Bug fixes

30 Mar 14:06
4135aa2
Compare
Choose a tag to compare
  • Added polyfill for missing PHP functions
  • Fixed some known bugs with gtm.js
  • Improved CSS for lazied images
  • Added simple caching prototype

Small bug fixes

25 Mar 09:43
c65b616
Compare
Choose a tag to compare
  • Small fix for IE
  • Fixed charset problems
  • Fixed crossorigin value
  • Added missing meta tags
  • Do not preload ads scripts
  • Code refactoring

Defer background images

24 Mar 14:22
4ce6fb1
Compare
Choose a tag to compare

Bug fixes

23 Mar 13:19
ffee3f4
Compare
Choose a tag to compare
  • Improved deferring scripts
  • Maintained placeholder image ratio
  • Do not remove spaces between inline elements

Optimized script loader

21 Mar 09:03
337bb55
Compare
Choose a tag to compare

Optimized script loader

Release version 1.0.0

19 Mar 18:07
Compare
Choose a tag to compare

defer.php

🔌 defer.php is a PHP helper class helping you to integrate my beloved defer.js library into your websites.

defer.js is a super tiny, native performant library for lazy-loading JS, CSS, images, iframes...

Easily speed up your website! Hope you guys like it.

How to use

Install with composer

composer require shinsenter/defer.php:dev-master

Basic usage

// Include the library
require_once __DIR__ . '/vendor/shinsenter/defer.php/defer.php';

// Create a Defer object
$defer = new \shinsenter\Defer();

// Process the HTML
$response->setContent($defer->from()->toHtml($html));

// Read HTML source from file
$html_source = file_get_contents('mypage.html');

// Then get the optimized output
$result = $defer->fromHtml($html_source)->toHtml($html);
var_dump($result);

// Load another HTML without creating new object
// You can write all methods in one line like this
$result = $defer->fromHtml(file_get_contents('otherpage.html'))->toHtml();
var_dump($result);

Library's options

// Include the library
require_once __DIR__ . '/vendor/shinsenter/defer.php/defer.php';

// Create a Defer object
$defer = new \shinsenter\Defer();

// Turn off warning and debug
$defer->debug_mode            = false;
$defer->hide_warnings         = true;

// Library injection
$defer->append_defer_js       = true;
$defer->default_defer_time    = 100;

// Page optimizations
$defer->enable_preloading     = true;
$defer->enable_dns_prefetch   = true;
$defer->fix_render_blocking   = true;
$defer->minify_output_html    = true;

// Tag optimizations
$defer->enable_defer_css      = true;
$defer->enable_defer_scripts  = false;
$defer->enable_defer_images   = true;
$defer->enable_defer_iframes  = true;

// Web-font optimizations
$defer->defer_web_fonts       = true;

// Image and iframe placeholders
$defer->empty_gif             = '';
$defer->empty_src             = '';
$defer->use_color_placeholder = true;

// Blacklist
$defer->do_not_optimize = [];

// Then get the optimized output
$result = $defer->fromHtml(file_get_contents('mypage.html'))->toHtml();
var_dump($result);

defer-wordpress

WordPress remains one of the most popular CMS platform until now. This is a WordPress plugin. Hope you guys like it.

Keep in touch

Become a sponsor

Follow my defer.js project:

https://github.com/shinsenter/defer.js/releases

https://github.com/shinsenter/defer.js/stargazers


Released under the MIT license.
https://appseeds.net/defer.php/LICENSE

Copyright (c) 2019 Mai Nhut Tan <shin@shin.company>