• 13-08-2021, 20:59:02
    #1
    Websayfanızı html olarak sıkıştıran eklenti ne işe yarar.

    Google page speed masaüstü %90-95 aralığında sıkıştırmaktadır.

    Örnek:
    https://developers.google.com/speed/...2F&tab=desktop


    indir:
    https://tr.wordpress.org/plugins/minify-html-markup/
  • 13-08-2021, 21:06:10
    #2
    Paylaşım için teşekkürler.
  • 13-08-2021, 21:07:35
    #3
    Rawt adlı üyeden alıntı: mesajı görüntüle
    Paylaşım için teşekkürler.
    bir çok eklenti bunun yaptığını yapmıyor. 2 satıra kodları sıkıştırıyor.
  • 13-08-2021, 21:14:39
    #4
    Bunu da kullanabilirsiniz;

    <?php
    ob_start("minifier");
    function minifier($code) {
        $search = array(
            // Remove whitespaces after tags
            '/>[^S ]+/s',
            
            // Remove whitespaces before tags
            '/[^S ]+</s',
            
            // Remove multiple whitespace sequences
            '/(s)+/s',
            
            // Removes comments
            '/<!--(.|s)*?-->/'
        );
        $replace = array('>', '<', '\1');
        $code = preg_replace($search, $replace, $code);
        return $code;
    }
    ?>
    <!DOCTYPE html>
    <html>
    <head>
    <!-- title of page -->
    <title>Demo for minifier</title>
    </head>
    
    <body>
    <!-- body of page -->
    <h1>Hello World</h1>
    </body>
    </html>
    
    <?php
    ob_end_flush();
    ?>
  • 13-08-2021, 21:17:11
    #5
    ibocum adlı üyeden alıntı: mesajı görüntüle
    Bunu da kullanabilirsiniz;

    <?php
    ob_start("minifier");
    function minifier($code) {
        $search = array(
            // Remove whitespaces after tags
            '/>[^S ]+/s',
            
            // Remove whitespaces before tags
            '/[^S ]+</s',
            
            // Remove multiple whitespace sequences
            '/(s)+/s',
            
            // Removes comments
            '/<!--(.|s)*?-->/'
        );
        $replace = array('>', '<', '1');
        $code = preg_replace($search, $replace, $code);
        return $code;
    }
    ?>
    <!DOCTYPE html>
    <html>
    <head>
    <!-- title of page -->
    <title>Demo for minifier</title>
    </head>
    
    <body>
    <!-- body of page -->
    <h1>Hello World</h1>
    </body>
    </html>
    
    <?php
    ob_end_flush();
    ?>
    Aslında wordpress funtions olarak yazılsa daha iyi olur.
    temaya Sıkıştırma funtion kodunu koyarız daha kolay olur.
  • 13-08-2021, 22:18:53
    #6
    webtasarimofisi adlı üyeden alıntı: mesajı görüntüle
    Aslında wordpress funtions olarak yazılsa daha iyi olur.
    temaya Sıkıştırma funtion kodunu koyarız daha kolay olur.
    Denemedim, deneyip cevap yazarsanız sevinirim

    add_action('get_header', 'pt_html_minify_start');
    function pt_html_minify_start()  {
        ob_start( 'pt_html_minyfy_finish' );
    }
    function pt_html_minyfy_finish( $html )  {
      $html = preg_replace('/<!--(?!s*(?:[if [^]]+]|!|>))(?:(?!-->).)*-->/s', '', $html);
      $html = str_replace(array("\r\n", "\r", "\n", "\t"), '', $html);
      while ( stristr($html, '  '))
         $html = str_replace('  ', ' ', $html);
     return $html;
    }
  • 13-08-2021, 22:21:57
    #7
    ibocum adlı üyeden alıntı: mesajı görüntüle
    Denemedim, deneyip cevap yazarsanız sevinirim

    add_action('get_header', 'pt_html_minify_start');
    function pt_html_minify_start()  {
        ob_start( 'pt_html_minyfy_finish' );
    }
    function pt_html_minyfy_finish( $html )  {
      $html = preg_replace('/<!--(?!s*(?:[if [^]]+]|!|>))(?:(?!-->).)*-->/s', '', $html);
      $html = str_replace(array("\r\n", "\r", "\n", "\t"), '', $html);
      while ( stristr($html, '  '))
         $html = str_replace('  ', ' ', $html);
     return $html;
    }
    Sağlam çalıştı. 52 /89 ama page speed
  • 13-08-2021, 22:31:06
    #8
    webtasarimofisi adlı üyeden alıntı: mesajı görüntüle
    Sağlam çalıştı. 52 /89 ama page speed
    Bu kod sadece HTML küçültüp tarayıcının daha hızlı okumasına yarar. Hız için biraz daha cache ve sunucunuzu kontrol etmeniz gerekiyor