From 5c4a8b3392ef7db5d6f84905ef028f4e146177db Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Thu, 5 Sep 2019 15:46:36 +0200 Subject: [PATCH] Require files manually in case there's no Composer Autoloader, to reduce plugin size. --- deploy.sh | 3 ++- native-lazyload.php | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index bf13ffa..9a0f9e9 100644 --- a/deploy.sh +++ b/deploy.sh @@ -101,7 +101,7 @@ cd $SVNPATH/trunk/ printf "Building assets..." rm -rf vendor -composer install --no-dev +composer install rm -rf node_modules npm install npm run build @@ -115,6 +115,7 @@ rm README.md rm -rf .github rm -rf node_modules rm -rf tests +rm -rf vendor echo "Done." printf "Ignoring GitHub specific files and deployment script..." diff --git a/native-lazyload.php b/native-lazyload.php index 72e5bd8..cf9a1aa 100644 --- a/native-lazyload.php +++ b/native-lazyload.php @@ -39,6 +39,12 @@ function native_lazyload_load() { if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) { require __DIR__ . '/vendor/autoload.php'; + } elseif ( ! class_exists( 'Google\\Native_Lazyload\\Plugin' ) ) { + $plugin_dir = plugin_dir_path( __FILE__ ); + require_once $plugin_dir . 'src/Plugin.php'; + require_once $plugin_dir . 'src/Context.php'; + require_once $plugin_dir . 'src/Lazy_Loader.php'; + require_once $plugin_dir . 'src/Lazy_Load_Script.php'; } call_user_func( [ 'Google\\Native_Lazyload\\Plugin', 'load' ], __FILE__ );