Modulshop - Eine große Auswahl an neuen und hilfreichen Modulen für die modified eCommerce Shopsoftware
Neuigkeiten
  • Die modified eCommerce Shopsoftware ist kostenlos, aber nicht umsonst.
    Spenden
  • Damit wir die modified eCommerce Shopsoftware auch zukünftig kostenlos anbieten können:
    Spenden
  • Thema: BETA MODUL: HTML Output Minify

    karabey

    • Schreiberling
    • Beiträge: 320
    • Geschlecht:
    Re: BETA MODUL: HTML Output Minify
    Antwort #30 am: 19. Juli 2013, 15:37:11
    Vielen Dank für den Info nur bei der Ausgabe unter 1.06 gibt es Fehler.

    includes/application_top.php
    nach:
    Code: PHP  [Auswählen]
       Released under the GNU General Public License
       ---------------------------------------------------------------------------------------*/
    einfügen
    Code: PHP  [Auswählen]
    //dh html - minify
    ob_start ();

    includes/application_bottom.php
    nach
    Code: PHP  [Auswählen]
    // end of page
    echo '</body>';
    echo '</html>';

    einfügen
    Code: PHP  [Auswählen]
    //dh html - minify
    $result = ob_get_clean();
    // BOF DJ-Ready - 2010-11-11 - html Output minify
    $regex = array('{\t|\r|\n}', '{(/\*(.*?)\*/)}', '/<!--(.*)-->/Uis',);
    echo preg_replace($regex, '', $result);
    // EOF DJ-Ready - 2010-11-11 - html Output minify

    Warum nicht nach ?> einfügen? Weil ich der Datei applications_bottom.php am Ende die PHP Datei nicht abgeschlossen wird. Schließe ich dennoch die Datei mit ?> und füge den Code ein gibt es ein Fehler. Egal mit oder ohne abschließung.

    Zitat
    Content-Encoding-Fehler
    Die Webseite, die Sie öffnen möchten, kann nicht angezeigt werden, da sie eine ungültige oder unbekannte Form der Kompression verwendet.
    Kontaktieren Sie bitte den Inhaber der Website, um ihn über dieses Problem zu informieren.
    Managed Server

    karabey

    • Schreiberling
    • Beiträge: 320
    • Geschlecht:
    Re: BETA MODUL: HTML Output Minify
    Antwort #31 am: 19. Juli 2013, 17:03:13
    Für den Regex habe ich da mal was

    Code: PHP  [Auswählen]
    function process_data_alan($text) //
    {
        $re = '%# Collapse ws everywhere but in blacklisted elements.
            (?>             # Match all whitespans other than single space.
              [^\S ]\s*     # Either one [\t\r\n\f\v] and zero or more ws,
            | \s{2,}        # or two or more consecutive-any-whitespace.
            ) # Note: The remaining regex consumes no text at all...
            (?=             # Ensure we are not in a blacklist tag.
              (?:           # Begin (unnecessary) group.
                (?:         # Zero or more of...
                  [^<]++    # Either one or more non-"<"
                | <         # or a < starting a non-blacklist tag.
                  (?!/?(?:textarea|pre)\b)
                )*+         # (This could be "unroll-the-loop"ified.)
              )             # End (unnecessary) group.
              (?:           # Begin alternation group.
                <           # Either a blacklist start tag.
                (?>textarea|pre)\b
              | \z          # or end of file.
              )             # End alternation group.
            )  # If we made it here, we are not in a blacklist tag.
            %ix'
    ;
        $text = preg_replace($re, " ", $text);
        return $text;
    }

    Quelle: http://stackoverflow.com/questions/5312349/minifying-final-html-output-using-regular-expressions-with-codeigniter

    mooncrawler

    • Mitglied
    • Beiträge: 104
    Re: BETA MODUL: HTML Output Minify
    Antwort #32 am: 24. Juli 2013, 10:51:14
    Code: PHP  [Auswählen]
    function process_data_alan($text) //
    {
        $re = '%# Collapse ws everywhere but in blacklisted elements.
            (?>             # Match all whitespans other than single space.
              [^\S ]\s*     # Either one [\t\r\n\f\v] and zero or more ws,
            | \s{2,}        # or two or more consecutive-any-whitespace.
            ) # Note: The remaining regex consumes no text at all...
            (?=             # Ensure we are not in a blacklist tag.
              (?:           # Begin (unnecessary) group.
                (?:         # Zero or more of...
                  [^<]++    # Either one or more non-"<"
                | <         # or a < starting a non-blacklist tag.
                  (?!/?(?:textarea|pre)\b)
                )*+         # (This could be "unroll-the-loop"ified.)
              )             # End (unnecessary) group.
              (?:           # Begin alternation group.
                <           # Either a blacklist start tag.
                (?>textarea|pre)\b
              | \z          # or end of file.
              )             # End alternation group.
            )  # If we made it here, we are not in a blacklist tag.
            %ix'
    ;
        $text = preg_replace($re, " ", $text);
        return $text;
    }

    Bei langsamen Rechnern braucht dieser Regex um die 10 Sekunden.
    5 Antworten
    2999 Aufrufe
    18. September 2012, 19:19:18 von trace70
    0 Antworten
    1818 Aufrufe
    26. Mai 2012, 01:23:24 von misterwong
    3 Antworten
    2922 Aufrufe
    25. März 2016, 14:21:37 von 0815
    11 Antworten
    5252 Aufrufe
    25. August 2011, 12:51:27 von Matt