Giter Site home page Giter Site logo

shinsenter / defer.php Goto Github PK

View Code? Open in Web Editor NEW
40.0 5.0 8.0 343 KB

🚀 A PHP library that focuses on minimizing payload size of HTML document and optimizing page speed.

Home Page: https://github.com/shinsenter/defer.php

License: MIT License

PHP 97.55% JavaScript 2.25% CSS 0.20%
lazyload lazy-loading lazy-loader lazy-js lazy-css lazy-image lazy-iframe lazy-video lazy-ads lazy-img

defer.php's People

Contributors

dependabot-preview[bot] avatar mnakalay avatar shinsenter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

defer.php's Issues

[Bug] Doesn't work on php5.6, codeigniter 3

Hi I have tested your project on my Codeigniter source code.

Wow it changed the html code structure amazingly. But there was a problem. I think it is caused by your defer.js component. It makes all image and js resources unloadable.

Best regards and good luck!

How do use width smarty template ?

Hi !

My project using smarty template engine it's synax bellow

require_once(SMARTY_DIR . 'Smarty.class.php');

$smarty = new Smarty();

$smarty->setTemplateDir('/web/www.example.com/guestbook/templates/');
$smarty->setCompileDir('/web/www.example.com/guestbook/templates_c/');
$smarty->setConfigDir('/web/www.example.com/guestbook/configs/');
$smarty->setCacheDir('/web/www.example.com/guestbook/cache/');

$smarty->assign('name','Ned');

//** un-comment the following line to show the debug console
//$smarty->debugging = true;

$smarty->display('index.tpl');

it's display through display function but shinsenter not like that it's output direct

Testing with Dev Master (v2.5)

Hi.

I am using this version Dev Master (v2.5) and got it all working.

I am using it in relation to Wordpress.

So if you have some updates you want to push, or mention, or test, feel free to let me know :) and I'll give it a run.

Add Deffer inline

DeepL Translation:
Can you insert an option for deffer_min.js. The one that inserts the script inline of HTMl and not external?

Kannst du eine Option für deffer_min.js einfügen. Die den den Script inline des HTMl einfügt und nicht externe?

Uncaught Error: Call to a member function get()

On My Framework what i use

Fatal error: Uncaught Error: Call to a member function get() on null in C:\xampp\htdocs\wcs\lib\system\api\defer.php\src\Defer.php:211 Stack trace: #0 C:\xampp\htdocs\wcs\lib\system\api\defer.php\src\Defer.php(78): shinsenter\Defer->nodefer() #1 C:\xampp\htdocs\wcs\lib\system\event\listener\OutputModListener.class.php(57): shinsenter\Defer->fromHtml('\r\n\r\n\r\n<!DOCTYPE...') #2 C:\xampp\htdocs\wcs\lib\system\event\EventHandler.class.php(221): wcf\system\event\listener\OutputModListener->execute('wcf\util\Header...', 'wcf\util\Header...', 'parseOutput', Array) #3 C:\xampp\htdocs\wcs\lib\util\HeaderUtil.class.php(140): wcf\system\event\EventHandler->fireAction('wcf\util\Header...', 'parseOutput') #4 [internal function]: wcf\util\HeaderUtil::parseOutput('\r\n\r\n\r\n<!DOCTYPE...', 9) #5 C:\xampp\htdocs\wcs\lib\system\WCF.class.php(191): ob_end_flush() #6 [internal function]: wcf\system\WCF::destruct() #7 {main} thrown in C:\xampp\htdocs\wcs\lib\system\api\defer.php\src\Defer.php on line 211

i musst change teh Follow Line https://github.com/shinsenter/defer.php/blob/master/src/Defer.php#L211 to
$has_nodefer = 0;

found a Broken Script

I have found a Script thats Broken all (No Console Error)

Before
001
Code-> https://paste.ee/p/ePXqY

After
002
Code-> https://paste.ee/p/aThOO

Setting

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

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

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

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

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

  	// Blacklist
  	$defer->do_not_optimize = [
  		'document\.write\s*\(',
  		'(jquery([-_][\d\.]+)?(\.min)?\.js|jquery-core)',
  		'partner',
  		'styleLogo'
  	];

feature request fully local

i wish me a fully local version of JS because General Data Protection Regulation GDPR (DSGVO)
i cant use external source and the Polyfill.js is includes as External source by me

Plugin does not work properly with caching (non-optimized version gets saved)

I think I posted this in the wrong github repo--I was sent to the defer.js one. Anyway, for some reason your optimized output does not get saved in the Cache Enabler cache. The author of Autoptimize says AO uses output buffering in order not to depend on any caching plugin.

Is it possible you could use this technique so yours gets cached, too? I prefer your plugin.

NORMALIZE_XPATH bug?

this code

<p>Na was machst du den hier, Möchtest du den Boss, Chef, Gott usw. des Forum mal genauer betrachten oder haste einfach Interesse an meiner Person und Persönlichkeit?<br><br>Naja dann wünsche ich dir Viel Spaß und hoffe deine Träume erfüllt mein Profile <img src="https://www.cafe-anime.de/_OLD/wcf/images/smilies/wink.png" alt=";)"></p>

after minifyOutputHTML
<p>Na was machst du den hier, Möchtest du den Boss, Chef, Gott usw. des Forum mal genauer betrachten oder haste einfach Interesse an meiner Person und Persönlichkeit?<br><br> Naja dann wünsche ich dir Viel Spaß und hoffe deine Träume erfüllt mein Profile<img alt=";)" class="defer-lazied defer-loaded" data-src="https://www.cafe-anime.de/_OLD/wcf/images/smilies/wink.png" src="https://www.cafe-anime.de/_OLD/wcf/images/smilies/wink.png" data-lazied="IMG"><noscript><img src="https://www.cafe-anime.de/_OLD/wcf/images/smilies/wink.png" alt=";)" class="jsResizeImage"></noscript></p>

after "Profile<" is a space missing

or

<p><strong>Avatar (<a href="https://www.cafe-anime.de/index.php?thread/17375-10-jahre-cafe-anime-cafe-anime-feiert-geburtstag/&amp;postID=514919#post514919">Vorlage</a>) by <a href="https://www.cafe-anime.de/index.php?user/5183-blacksad/">Blacksad</a>, Danke</strong></p>

after
<p><strong>Avatar (<a href="https://www.cafe-anime.de/index.php?thread/17375-10-jahre-cafe-anime-cafe-anime-feiert-geburtstag/&amp;postID=514919#post514919">Vorlage</a> ) by<a href="https://www.cafe-anime.de/index.php?user/5183-blacksad/">Blacksad</a>, Danke</strong></p>

by "by<a" missing space

Wrong HTML entity encoding in attribute

The website is: dentzar.com.
Please click on the Search button and you’ll see strange looking box.

Original HTML:

data-avia-search-tooltip="&lt;form role=&quot;search&quot; action=&quot;https://dentzar.com/&quot; id=&quot;searchform&quot; method=&quot;get&quot; class=&quot;&quot;&gt;
&lt;div&gt;
&lt;input type=&quot;submit&quot; value=&quot;&quot; id=&quot;searchsubmit&quot; class=&quot;button avia-font-entypo-fontello&quot; /&gt;
&lt;input type=&quot;text&quot; id=&quot;s&quot; name=&quot;s&quot; value=&quot;&quot; placeholder='Search' /&gt;
&lt;/div&gt;
&lt;/form&gt;"

Defer.js optimized HTML:

data-avia-search-tooltip="&lt;form role=&amp;quot;search&amp;quot; action=&amp;quot;https://dentzar.com/&amp;quot; id=&amp;quot;searchform&amp;quot; method=&amp;quot;get&amp;quot; class=&amp;quot;&amp;quot;&gt;
&lt;div&gt;
&lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;&amp;quot; id=&amp;quot;searchsubmit&amp;quot; class=&amp;quot;button avia-font-entypo-fontello&amp;quot; /&gt;
&lt;input type=&amp;quot;text&amp;quot; id=&amp;quot;s&amp;quot; name=&amp;quot;s&amp;quot; value=&amp;quot;&amp;quot; placeholder='Search' /&gt;
&lt;/div&gt;
&lt;/form&gt;"

Reason: wrong HTML entity encoding.
Schedule: Fix in the next release
Temporary fix: None

Got Warning Deprecated

Deprecated: Return type of AppSeeds\Elements\DocumentNode::normalize() should either be compatible with DOMNode::normalize(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in \vendor\shinsenter\defer.php\src\Elements\DocumentNode.php on line 272

Deprecated: DOMDocument::createElement(): Passing null to parameter #2 ($value) of type string is deprecated in \vendor\shinsenter\defer.php\src\Elements\DocumentNode.php on line 197

how to fix it?

Parser's issue with scripts containing closing tags

Hello,
Whenever the page contains a script which contains a closing HTML tag, the parser gets it wrong and adds a closing </script> tag right in the middle

For instance this

$('<div class="bg-color-overlay"></div>').prependTo('body');

becomes this

$('<div class="bg-color-overlay"></script></div>').prependTo('body');

And breaks everything.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.