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

Commit

Permalink
Merge pull request #63 from shinsenter/develop
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
shinsenter authored Apr 16, 2021
2 parents 0eb9830 + 3b133ad commit b097d36
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
🚀 A PHP library that aims to help you concentrate on web performance optimization.

- **Package**: [@shinsenter/defer.php](https://packagist.org/packages/shinsenter/defer.php)
- **Version**: 2.2.0
- **Version**: 2.4.0
- **Author**: Mai Nhut Tan <shin@shin.company>
- **Copyright**: 2021 AppSeeds <https://code.shin.company/>
- **License**: [MIT](https://raw.githubusercontent.com/shinsenter/defer.php/master/LICENSE)
Expand Down Expand Up @@ -383,7 +383,9 @@ Only few options of this library are applicable to AMP pages (minifying HTML con

### Laravel package

Under development.
[https://github.com/shinsenter/defer-laravel/](https://github.com/shinsenter/defer-laravel/)

🚀 A Laravel package that focuses on minimizing payload size of HTML document and optimizing processing on the browser when rendering the web page.


## Support my activities
Expand Down
4 changes: 2 additions & 2 deletions src/Resolvers/DeferResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function skipLazyloading($attr = 'src')

if (!empty($value)) {
foreach ($blacklist as $keyword) {
if (strstr($value, $keyword) !== true) {
if (strstr($value, $keyword) !== false) {
return true;
}
}
Expand All @@ -243,7 +243,7 @@ public function skipLazyloading($attr = 'src')

if (!empty($text)) {
foreach ($blacklist as $keyword) {
if (strstr($text, $keyword) !== true) {
if (strstr($text, $keyword) !== false) {
return true;
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/Resolvers/LinkResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,9 @@ public function lazyload()
{
// Only defer when it is a CSS node
// and "onload" attribute is not provided
if (!$this->isCss() || $this->node->hasAttribute('onload')) {
if (!$this->isCss() ||
$this->node->hasAttribute('onload') ||
$this->skipLazyloading('href')) {
return false;
}

Expand Down
4 changes: 3 additions & 1 deletion src/Resolvers/ScriptResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ public function shouldLazyload()
*/
public function lazyload()
{
if ($this->isDeferJs() || $this->isCriticalJavascript()) {
if ($this->isDeferJs() ||
$this->isCriticalJavascript() ||
$this->skipLazyloading('src')) {
return false;
}

Expand Down
5 changes: 4 additions & 1 deletion tests/v2/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,12 @@
'iframe_placeholder' => 'about:blank',

// Splash screen
'custom_splash_screen' => '',
'custom_splash_screen' => '<div id="loading"></div>',

// Blacklists
'ignore_lazyload_paths' => [
'jquery',
],
'ignore_lazyload_css_class' => [
'zoom-lens',
],
Expand Down

0 comments on commit b097d36

Please sign in to comment.