• Resolved Can

    (@candanbl0g)


    Hi futtta,

    Firstly, thanks for this great plugin, it works like a charm-ish ?? There are two problems I have encountered.

    First, the plugin prints a second </body> just after its comment in footer, although there is one body closing tag coming ftom my theme. You can observe this problem by checking the source code in my website candanblog.com.

    Secondly, if I use HTML optimization, the browser shows only the light-blue background of my website, nothing else. In this situation, source code is like below:

    <!DOCTYPE html><html class="no-js" lang="tr-TR"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0"><link type="text/css" media="all" href="https://www.candanblog.com/wp-content/cache/autoptimize/autoptimize_9b1ceee5358433006338535585dd47d2.css" rel="stylesheet" /><title>CandanBlog - ?zgün, Güncel, Keyifli Blog!</title><link rel="pingback" href="https://www.candanblog.com/xmlrpc.php"><link rel="author" href="https://plus.google.com/+CanAtasever/"/><link rel="alternate" type="application/rss+xml" title="CandanBlog! &raquo; Beslemesi" href="https://feeds.feedburner.com/candanblog" /><link rel="alternate" type="application/rss+xml" title="CandanBlog! &raquo; Yorum Beslemesi" href="https://www.candanblog.com/comments/feed/" /><link href="https://fonts.googleapis.com/css?family=Titillium+Web:400,400italic,300italic,300,600&subset=latin,latin-ext" rel="stylesheet" type="text/css"><link rel="shortcut icon" href="https://www.candanblog.com/favicon.ico" /> <!--[if lt IE 9]> <script src="https://www.candanblog.com/wp-content/themes/hueman/js/ie/html5.js"></script> <script src="https://www.candanblog.com/wp-content/themes/hueman/js/ie/selectivizr.js"></script> <![endif]--><meta name="description" content="Can ATASEVER taraf?ndan y?netilen ve yazarlar taraf?ndan desteklenen CandanBlog, tamamen ?zgün ve güncel i?eri?iyle takip edilesi, keyifli bir blog!" /><link rel='next' href='https://www.candanblog.com/page/2/' /><link rel="canonical" href="https://www.candanblog.com" /><meta property="fb:app_id" content="476968765687683"/><meta property="og:url" content="https://www.candanblog.com"/><meta property="og:title" content="CandanBlog - ?zgün, Güncel, Keyifli Blog!"></script></body><!--noptimize--><!-- Autoptimize found a problem with the HTML in your Theme, check if the title or body-tags are missing --><!--/noptimize--></body>
    </html>
    <!-- Dynamic page generated in 1.376 seconds. -->
    <!-- Page not cached by WP Super Cache. Check your settings page. Not caching requests by known users. (See Advanced Settings page) -->

    The second problem I mentioned is not that important as HTML optimization has small effect on performance, but be advised.

    Which php file prints that second body tag?

    https://www.ads-software.com/plugins/autoptimize/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Frank Goossens

    (@futtta)

    I have seen the closing-body problem before on someone else’s site, but have not been able to reproduce it myself (as a first step towards fixing it), so I would be interested in doing some tests with your theme. Can I download it somewhere?

    Thread Starter Can

    (@candanbl0g)

    Yes, I saw that post about the same problem.

    Sure, it can be downloaded from https://alxmedia.se/themes/hueman/

    Plugin Author Frank Goossens

    (@futtta)

    hmm, I tested with that theme and can’t reproduce the double body ending. What plugins are you using?

    Thread Starter Can

    (@candanbl0g)

    None of the plugins being used are about footer.php, and I have deactivated them one by one to see whether the problem arises from a plugin – but the answer is no.

    How can I prevent Autoptimize to print </body> tag? This can be a temporary solution for now.

    Plugin Author Frank Goossens

    (@futtta)

    I’ve got a (workaround) fix in the works for the next minor release. If you want, you can apply it now by following these steps;

    1. open wp-content/plugins/autoptimize/classes/autoptimizeScripts.php
    2. on line 220 find this block of code:
      $bodyreplacement = implode('',$this->move['first']);
      $bodyreplacement .= '<script type="text/javascript" '.$defer.'src="'.$this->url.'"></script>';
      $bodyreplacement .= implode('',$this->move['last']).$replaceTag;
      
      if (strpos($this->content,$replaceTag)!== false) {
      	$this->content = str_replace($replaceTag,$bodyreplacement,$this->content);
      } else {
      	$this->content .= $bodyreplacement;
      	$this->warn_html();
      }
    3. and replace it with this block:
      $bodyreplacement = implode('',$this->move['first']);
      $bodyreplacement .= '<script type="text/javascript" '.$defer.'src="'.$this->url.'"></script>';
      $bodyreplacement .= implode('',$this->move['last']);
      
      if (strpos($this->content,$replaceTag)!== false) {
      	$this->content = str_replace($replaceTag,$bodyreplacement.$replaceTag,$this->content);
      } else {
      	$this->content .= $bodyreplacement;
      	$this->warn_html();
      }
    4. save and close the file
    5. empty autoptimize cache

    Let me know how that works for you!

    frank

    Thread Starter Can

    (@candanbl0g)

    Yep, it works about the second </body> tag. But the message “Autoptimize found a problem with the HTML …” is still there although both of the <title> and <body> tags are found and complete in my theme.

    I will also look for the cause of this problem, gonna let you know if I find it out. Thanks for your attention.

    Plugin Author Frank Goossens

    (@futtta)

    re.: “the message found a problem with the HTML”; yeah it’s just a workaround for the double closing body tag.

    hope you indeed can find the root cause; if your theme works on my (test-)blog and if disabling plugins did not fix it, then this isn’t an easy thing to find & fix. based on what AO does, either the content in the output buffer is not the entire HTML (which autoptimize expects) or the ouput buffer has the full HTML but the closing tag isn’t in there (in a way that strpos can find it, maybe encoded for one reason or another).

    Plugin Author Frank Goossens

    (@futtta)

    The above workaround has been included in the test-version of 1.8.5, which I just committed to the trunk-build. Would be great if you could download & test to confirm this does work?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Works like a charm – But I have two problems’ is closed to new replies.