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

Commit 23d9508

Browse files
authored
Merge pull request #38 from shinsenter/v2.0
Updated v2.0.0-beta
2 parents be55147 + c3f9827 commit 23d9508

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2383
-2275
lines changed
File renamed without changes.

.dist/blacklist.txt

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
.*
2+
.dist
3+
.docker
4+
*Test*.php
5+
composer.*
6+
node_modules/
7+
package-lock.json
8+
package.json
9+
README.md
10+
sonar-*
11+
test/
12+
Test/
13+
tests/
14+
Tests/
15+
VERSION
16+
17+
vendor/**/.editorconfig
18+
vendor/**/.git
19+
vendor/**/.gitattributes
20+
vendor/**/.github
21+
vendor/**/.gitignore
22+
vendor/**/.php_cs*
23+
vendor/**/.phpstorm.meta.php
24+
vendor/**/.scrutinizer
25+
vendor/**/*.dist
26+
vendor/**/*.md
27+
vendor/**/*.neon
28+
vendor/**/*.txt
29+
vendor/**/*.xml
30+
vendor/**/*.yml
31+
vendor/**/changelog*
32+
vendor/**/changes*
33+
vendor/**/composer.*
34+
vendor/**/contributing*
35+
vendor/**/demo
36+
vendor/**/doc
37+
vendor/**/dockerfile
38+
vendor/**/Dockerfile
39+
vendor/**/docs
40+
vendor/**/example
41+
vendor/**/examples
42+
vendor/**/faq*
43+
vendor/**/history*
44+
vendor/**/package-lock.json
45+
vendor/**/package.json
46+
vendor/**/phpunit.*
47+
vendor/**/readme*
48+
vendor/**/README*
49+
vendor/**/sonar-project.properties
50+
vendor/**/test
51+
vendor/**/tests
52+
vendor/**/travis
53+
vendor/**/upgrade*
54+
vendor/**/upgrading*
55+
56+
defer.php/.docker/
57+
defer.php/assets/
58+
defer.php/public/lib/

_dist_/deploy.sh renamed to .dist/deploy.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@
77

88
rm -Rf vendor
99
base_dir=`pwd`
10-
build_dir=$base_dir/_dist_/build
10+
build_dir=$base_dir/.dist/build
1111

12-
composer install -o -a -n --no-dev --prefer-dist --no-suggest
12+
# Install modules
13+
composer pull
1314

15+
# Prepare
1416
plugin_url=https://plugins.svn.wordpress.org/
1517
plugin_name=shins-pageload-magic
1618
plugin_svn=$plugin_url/$plugin_name
1719
plugin_dir=$build_dir/$plugin_name
18-
black_list=$base_dir/_dist_/blacklist.txt
20+
black_list=$base_dir/.dist/blacklist.txt
1921

2022
version=`head -n 1 $base_dir/VERSION`
2123

@@ -39,7 +41,7 @@ svn rm trunk/* --force
3941
cd $base_dir
4042
rsync -aHxW --delete --exclude-from=$black_list $base_dir/ $plugin_dir/trunk/
4143
mv $plugin_dir/trunk/defer-wordpress.php $plugin_dir/trunk/$plugin_name.php
42-
composer fixer _dist_
44+
composer fixer .dist
4345
echo ""
4446

4547
# ------------------------------------------------------------------------------

.docker/data/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

.docker/docker-compose.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: '3.3'
2+
3+
services:
4+
mariadb:
5+
image: mariadb:10.5
6+
volumes:
7+
- "./data:/var/lib/mysql"
8+
environment:
9+
MYSQL_ROOT_PASSWORD: somewordpress
10+
MYSQL_DATABASE: wordpress
11+
MYSQL_USER: wordpress
12+
MYSQL_PASSWORD: wordpress
13+
wordpress:
14+
container_name: defer-wp
15+
hostname: defer-wp-test
16+
depends_on:
17+
- mariadb
18+
image: wordpress:php5.6
19+
ports:
20+
- "8000:80"
21+
volumes:
22+
- "./wordpress/:/var/www/html"
23+
- "../:/var/www/html/wp-content/plugins/defer-wordpress"
24+
environment:
25+
WORDPRESS_DB_HOST: mariadb:3306
26+
WORDPRESS_DB_USER: wordpress
27+
WORDPRESS_DB_PASSWORD: wordpress
28+
WORDPRESS_DB_NAME: wordpress

.docker/wordpress/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ wp-content/uploads/
1010
wp-content/mu-plugins/
1111
wp-content/wp-cache-config.php
1212
wp-content/plugins/hello.php
13-
1413
/.htaccess
1514
/license.txt
1615
/readme.html
1716
/sitemap.xml
1817
/sitemap.xml.gz
1918
.php_cs.cache
2019
composer.phar
21-
/vendor/
20+
/.old/
21+
/vendor/
22+
/node_modules/

.php_cs

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,43 @@
11
<?php
22

33
/**
4-
* 🔌 A Wordpress plugin integrating my beloved "defer.js" library
5-
* into your websites. Hope you guys like it.
6-
* (c) 2019 AppSeeds Team <hello@appseeds.net>
4+
* 🚀 A WordPress plugin that focuses on minimizing payload size of HTML document
5+
* and optimizing processing on the browser when rendering the WordPress page.
6+
* (c) 2021 AppSeeds <hello@appseeds.net>
77
*
8-
* @author Mai Nhut Tan <shin@shin.company>
9-
* @copyright 2019 AppSeeds
8+
* PHP Version >=5.6
9+
*
10+
* @category Web_Performance_Optimization
1011
* @package defer-wordpress
11-
* @see https://code.shin.company/defer-wordpress/
12+
* @author Mai Nhut Tan <shin@shin.company>
13+
* @copyright 2021 AppSeeds
14+
* @license https://code.shin.company/defer-wordpress/blob/master/LICENSE GNU
15+
* @link https://code.shin.company/defer-wordpress
16+
* @see https://code.shin.company/defer-wordpress/blob/master/README.md
1217
*/
1318

1419
$header = <<<'EOF'
15-
🔌 A Wordpress plugin integrating my beloved "defer.js" library
16-
into your websites. Hope you guys like it.
17-
(c) 2019 AppSeeds Team <hello@appseeds.net>
20+
🚀 A WordPress plugin that focuses on minimizing payload size of HTML document
21+
and optimizing processing on the browser when rendering the WordPress page.
22+
(c) 2021 AppSeeds <hello@appseeds.net>
1823
19-
@author Mai Nhut Tan <shin@shin.company>
20-
@copyright 2019 AppSeeds
24+
PHP Version >=5.6
25+
26+
@category Web_Performance_Optimization
2127
@package defer-wordpress
22-
@see https://code.shin.company/defer-wordpress/
28+
@author Mai Nhut Tan <shin@shin.company>
29+
@copyright 2021 AppSeeds
30+
@license https://code.shin.company/defer-wordpress/blob/master/LICENSE GPL-2.0
31+
@link https://code.shin.company/defer-wordpress
32+
@see https://code.shin.company/defer-wordpress/blob/master/README.md
2333
EOF;
2434

2535
$rules = [
2636
'@Symfony' => true,
2737
'@PSR2' => true,
2838
'align_multiline_comment' => true,
2939
'array_indentation' => true,
30-
'array_syntax' => ['syntax' => 'long'],
40+
'array_syntax' => ['syntax' => 'short'],
3141
'braces' => ['allow_single_line_closure' => true],
3242
'combine_consecutive_issets' => true,
3343
'combine_consecutive_unsets' => true,
@@ -92,13 +102,13 @@ $rules = [
92102
];
93103

94104
$finder = \PhpCsFixer\Finder::create()
95-
->in(__DIR__)
105+
->in(__DIR__ . DIRECTORY_SEPARATOR)
96106
->name('*.php')
97-
->exclude('.idea')
98-
->exclude('.ppm')
107+
->exclude('.dist')
108+
->exclude('.docker')
99109
->exclude('cache')
100110
->ignoreDotFiles(true)
101-
->ignoreVCS(false);
111+
->ignoreVCS(true);
102112

103113
return \PhpCsFixer\Config::create()
104114
->setFinder($finder)

README.md

Lines changed: 110 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# defer-wordpress
22

3-
🔌 WordPress remains one of the most popular CMS platform until now, and I'm excited to make a Wordpress plugin integrating my beloved "defer.js" library into your websites. Hope you guys like it.
3+
⚡️ A native, blazing fast lazy loader. ✅ Legacy browsers support (IE9+). 💯 SEO friendly. 🧩 Lazy-load everything.
4+
5+
Download: [https://wordpress.org/plugins/shins-pageload-magic/](https://wordpress.org/plugins/shins-pageload-magic/)
46

57
![HitCount](http://hits.dwyl.com/shinsenter/defer-wordpress.svg)
68
![GitHub](https://img.shields.io/github/license/shinsenter/defer-wordpress.svg)
@@ -11,19 +13,117 @@
1113
![GitHub Release Date](https://img.shields.io/github/release-date/shinsenter/defer-wordpress.svg)
1214

1315

16+
This plugin helps you to optimize everything like image tags, video, audio, iframes as well as stylesheets, and JavaScript.
17+
18+
This plugin incorporates tips used a lot by experienced web experts, as well as making the most of the latest web technologies in lazy-loading resources on the page.
19+
20+
Rate [5 stars (⭐️⭐️⭐️⭐️⭐️)](https://wordpress.org/support/plugin/shins-pageload-magic/reviews/?filter=5) if you guys like it.
21+
22+
23+
## Good points
24+
25+
- ⚡️ Native API, blazing fast
26+
- 👍 Legacy browsers support (IE9+)
27+
- 🥇 SEO friendly
28+
- ✅ Very easy to use
29+
- 💯 No dependencies, no jQuery
30+
- 🤝 Works well with your favorite frameworks
31+
- 🧩 Uses [IntersectionObserver API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) for optimized CPU usage
32+
- 🏞 Supports for responsive images, both `srcset` and `sizes` attributes
33+
34+
💡 Tip: To archive better result, you should consider disabling all optimization features (Eg. lazy-loading, HTML minification, JS minification, etc.) by other plugins.
35+
36+
We recommend you use it with another page-caching plugin for best performance.
37+
38+
39+
## Browser support
40+
41+
Available in latest browsers. This library also works perfectly with Internet Explorer 9 and later.
42+
43+
- 🖥 IE9+ / Microsoft EDGE *
44+
- 🖥 Firefox 4+
45+
- 🖥 Safari 3+
46+
- 🖥 Chrome *
47+
- 🖥 Opera *
48+
- 📱 Android 4+
49+
- 📱 iOS 3.2+
50+
51+
52+
## Powered by defer.php
53+
54+
[defer.php](https://github.com/shinsenter/defer.php) is a library that focuses on minimizing payload size of HTML document and optimizing processing on the browser when rendering web pages.
55+
56+
- [x] Simplify library options
57+
- [x] Embed defer.js library
58+
- [x] Normalize DOM elements
59+
- [x] Fix missing meta tags
60+
- [x] Fix missing media attributes
61+
- [x] Preconnect to required origins
62+
- [x] Preload key requests
63+
- [x] Prefetch key requests
64+
- [x] Browser-level image lazy-loading for the web
65+
- [x] Lazy-load offscreen and hidden iframes
66+
- [x] Lazy-load offscreen and hidden videos
67+
- [x] Lazy-load offscreen and hidden images
68+
- [x] Lazy-load CSS background images
69+
- [x] Reduce the impact of JavaScript
70+
- [x] Defer non-critical CSS requests
71+
- [x] Defer third-party assets
72+
- [x] Add fallback `<noscript>` tags for lazy-loaded objects
73+
- [x] Add custom HTML while browser is rendering the page (splashscreen)
74+
- [x] Attribute to ignore optimizing the element
75+
- [x] Attribute to ignore lazyloading the element
76+
- [x] Optimize AMP document
77+
- [x] Minify HTML output
78+
79+
80+
## Why should I lazy-load my content?
81+
82+
The loading of contents on web page may make your load speed more slow, no one likes staring at a blank white page; users are impatient and will leave quickly.
83+
84+
Lazy loading content on web page can help reduce resource contention and improve performance.
85+
86+
87+
## Why should I use this plugin?
88+
89+
This plugin supports you to handle some common tips to help your website optimize the download of on-page resources.
90+
91+
These tips are published at [following website](https://web.dev/) by Google Developers, if you are interested you can consult to understand more about website optimization.
92+
93+
You can also manually implement these tips your-self, but it takes a lot of time and requires a lot of expertise.
94+
95+
96+
## How does this plugin work?
97+
98+
This plugin helps you to optimize everything like image tags, video, audio, iframes as well as stylesheets, and JavaScript.
99+
100+
This plugin incorporates tips used a lot by experienced web experts, as well as making the most of the latest web technologies in lazy-loading resources on the page.
101+
102+
Among them are creating "data-src" attributes to laza-load the media, even the [loading="lazy" feature](https://web.dev/browser-level-image-lazy-loading/) recently introduced by Google Developers.
103+
104+
105+
## High performance and accuracy
106+
107+
In addition, this plugin uses DOM to process the website structure so it produces accurate results and is faster than any other plugin that uses HTML text processing.
108+
109+
You can give it a try and I believe you will be surprised by the results it brings to your website.
110+
111+
112+
## Stable performance and high compatibility
113+
114+
We have tested this plugin with quite a few others and have not found any significant conflicts.
115+
116+
For best use of this plugin, you should consider disabling all optimization features (Eg. lazy-loading, HTML minification, JS minification, etc.) by other plugins.
14117

15-
## Keep in touch
118+
We recommend you use it with another page-caching plugin for best performance.
16119

17-
[![Donate via Paypal](https://pics.paypal.com/00/s/NTQ4M2ZiN2YtZDg1My00ZmRiLWJiMDQtMTFlMjg2ODY2N2Uy/file.PNG)](https://www.paypal.me/shinsenter)
18120

19-
[![Become a sponsor](https://c5.patreon.com/external/logo/become_a_patron_button@2x.png)](https://www.patreon.com/appseeds)
121+
## Support my activities
20122

21-
- Keep up-to-date with new releases:
22-
[https://wordpress.org/plugins/shins-pageload-magic/](https://wordpress.org/plugins/shins-pageload-magic/)
23-
- Become a stargazer:
24-
[https://github.com/shinsenter/defer.js/stargazers](https://github.com/shinsenter/defer.js/stargazers)
25-
- Report an issue:
26-
[https://github.com/shinsenter/defer.js/issues](https://github.com/shinsenter/defer.js/issues)
123+
[![Donate via Paypal](https://img.shields.io/badge/Donate-Paypal-blue)](https://www.paypal.me/shinsenter)
124+
[![Become a sponsor](https://img.shields.io/badge/Donate-Patreon-orange)](https://www.patreon.com/appseeds)
125+
[![Become a stargazer](https://img.shields.io/badge/Support-Stargazer-yellow)](https://github.com/shinsenter/defer-wordpress/stargazers)
126+
[![Report an issue](https://img.shields.io/badge/Support-Issues-red)](https://github.com/shinsenter/defer-wordpress/issues/new)
27127

28128
---
29129

0 commit comments

Comments
 (0)