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

Commit b097d36

Browse files
authored
Merge pull request #63 from shinsenter/develop
Bug fixes
2 parents 0eb9830 + 3b133ad commit b097d36

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
🚀 A PHP library that aims to help you concentrate on web performance optimization.
44

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

384384
### Laravel package
385385

386-
Under development.
386+
[https://github.com/shinsenter/defer-laravel/](https://github.com/shinsenter/defer-laravel/)
387+
388+
🚀 A Laravel package that focuses on minimizing payload size of HTML document and optimizing processing on the browser when rendering the web page.
387389

388390

389391
## Support my activities

src/Resolvers/DeferResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public function skipLazyloading($attr = 'src')
229229

230230
if (!empty($value)) {
231231
foreach ($blacklist as $keyword) {
232-
if (strstr($value, $keyword) !== true) {
232+
if (strstr($value, $keyword) !== false) {
233233
return true;
234234
}
235235
}
@@ -243,7 +243,7 @@ public function skipLazyloading($attr = 'src')
243243

244244
if (!empty($text)) {
245245
foreach ($blacklist as $keyword) {
246-
if (strstr($text, $keyword) !== true) {
246+
if (strstr($text, $keyword) !== false) {
247247
return true;
248248
}
249249
}

src/Resolvers/LinkResolver.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,9 @@ public function lazyload()
287287
{
288288
// Only defer when it is a CSS node
289289
// and "onload" attribute is not provided
290-
if (!$this->isCss() || $this->node->hasAttribute('onload')) {
290+
if (!$this->isCss() ||
291+
$this->node->hasAttribute('onload') ||
292+
$this->skipLazyloading('href')) {
291293
return false;
292294
}
293295

src/Resolvers/ScriptResolver.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,9 @@ public function shouldLazyload()
195195
*/
196196
public function lazyload()
197197
{
198-
if ($this->isDeferJs() || $this->isCriticalJavascript()) {
198+
if ($this->isDeferJs() ||
199+
$this->isCriticalJavascript() ||
200+
$this->skipLazyloading('src')) {
199201
return false;
200202
}
201203

tests/v2/test.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,12 @@
6868
'iframe_placeholder' => 'about:blank',
6969

7070
// Splash screen
71-
'custom_splash_screen' => '',
71+
'custom_splash_screen' => '<div id="loading"></div>',
7272

7373
// Blacklists
74+
'ignore_lazyload_paths' => [
75+
'jquery',
76+
],
7477
'ignore_lazyload_css_class' => [
7578
'zoom-lens',
7679
],

0 commit comments

Comments
 (0)