protected function maybeCompressCombineFooterJs($html)
    {
        if (($benchmark = !empty($this->options['benchmark']) && $this->options['benchmark'] === 'details')) {
            $time = microtime(true);
        }
        $html = (string) $html; // Force string value.

        if (isset($this->options['compress_combine_footer_js'])) {
            if (!$this->options['compress_combine_footer_js']) {
                $disabled = true; // Disabled flag.
            }
        }
        if (!$html || !empty($disabled)) {
            goto finale; // Nothing to do.
        }
        if (($footer_scripts_frag = $this->getFooterScriptsFrag($html)) /* e.g. <!-- footer-scripts --><!-- footer-scripts --> */) {
            if (($js_tag_frags = $this->getJsTagFrags($footer_scripts_frag)) && ($js_parts = $this->compileJsTagFragsIntoParts($js_tag_frags, 'foot'))) {
                $js_tag_frags_all_compiled = $this->compileKeyElementsDeep($js_tag_frags, 'all');
                $html                      = $this->replaceOnce($footer_scripts_frag['all'], '%%htmlc-footer-scripts%%', $html);
                $cleaned_footer_scripts    = $this->replaceOnce($js_tag_frags_all_compiled, '', $footer_scripts_frag['contents']);

                $compressed_js_tags = []; // Initialize.

                foreach ($js_parts as $_js_part) {
                    if (isset($_js_part['exclude_frag'], $js_tag_frags[$_js_part['exclude_frag']]['all'])) {
                        $compressed_js_tags[] = $js_tag_frags[$_js_part['exclude_frag']]['all'];
                    } else {
                        $compressed_js_tags[] = $_js_part['tag'];
                    }
                } // unset($_js_part); // Housekeeping.

                $compressed_js_tags             = implode("\n", $compressed_js_tags);
                $compressed_footer_script_parts = [$footer_scripts_frag['open_tag'], $cleaned_footer_scripts, $compressed_js_tags, $footer_scripts_frag['closing_tag']];
                $html                           = $this->replaceOnce('%%htmlc-footer-scripts%%', implode("\n", $compressed_footer_script_parts), $html);

                if ($benchmark) {
                    $this->benchmark->addData(
                        __FUNCTION__,
                        compact(
                            'footer_scripts_frag',
                            'js_tag_frags',
                            'js_parts',
                            'cleaned_footer_scripts',
                            'compressed_js_tags',
                            'compressed_footer_script_parts'
                        )
                    );
                }
            }
        }
        finale: // Target point; finale/return value.

        if ($html) {
            $html = trim($html);
        } // Trim it up now!

        if ($benchmark && !empty($time) && $html && empty($disabled)) {
            $this->benchmark->addTime(
                __FUNCTION__,
                $time, // Caller, start time, task performed.
                sprintf('compressing/combining footer JS in checksum: `%1$s`', md5($html))
            );
        }
        return $html; // With possible compression having been applied here.
    }
protected function maybeCompressCombineFooterJs($html)
    {
        if (($benchmark = !empty($this->options['benchmark']) && $this->options['benchmark'] === 'details')) {
            $time = microtime(true);
        }
        $html = (string) $html; // Force string value.

        if (isset($this->options['compress_combine_footer_js'])) {
            if (!$this->options['compress_combine_footer_js']) {
                $disabled = true; // Disabled flag.
            }
        }
        if (!$html || !empty($disabled)) {
            goto finale; // Nothing to do.
        }
        if (($footer_scripts_frag = $this->getFooterScriptsFrag($html)) /* e.g. <!-- footer-scripts --><!-- footer-scripts --> */) {
            if (($js_tag_frags = $this->getJsTagFrags($footer_scripts_frag)) && ($js_parts = $this->compileJsTagFragsIntoParts($js_tag_frags, 'foot'))) {
                $js_tag_frags_all_compiled = $this->compileKeyElementsDeep($js_tag_frags, 'all');
                $html                      = $this->replaceOnce($footer_scripts_frag['all'], '%%htmlc-footer-scripts%%', $html);
                $cleaned_footer_scripts    = $this->replaceOnce($js_tag_frags_all_compiled, '', $footer_scripts_frag['contents']);

                $compressed_js_tags = []; // Initialize.

                foreach ($js_parts as $_js_part) {
                    if (isset($_js_part['exclude_frag'], $js_tag_frags[$_js_part['exclude_frag']]['all'])) {
                        $compressed_js_tags[] = $js_tag_frags[$_js_part['exclude_frag']]['all'];
                    } else {
                        $compressed_js_tags[] = $_js_part['tag'];
                    }
                } // unset($_js_part); // Housekeeping.

                $compressed_js_tags             = implode("\n", $compressed_js_tags);
                $compressed_footer_script_parts = [$footer_scripts_frag['open_tag'], $cleaned_footer_scripts, $compressed_js_tags, $footer_scripts_frag['closing_tag']];
                $html                           = $this->replaceOnce('%%htmlc-footer-scripts%%', implode("\n", $compressed_footer_script_parts), $html);

                if ($benchmark) {
                    $this->benchmark->addData(
                        __FUNCTION__,
                        compact(
                            'footer_scripts_frag',
                            'js_tag_frags',
                            'js_parts',
                            'cleaned_footer_scripts',
                            'compressed_js_tags',
                            'compressed_footer_script_parts'
                        )
                    );
                }
            }
        }
        finale: // Target point; finale/return value.

        if ($html) {
            $html = trim($html);
        } // Trim it up now!

        if ($benchmark && !empty($time) && $html && empty($disabled)) {
            $this->benchmark->addTime(
                __FUNCTION__,
                $time, // Caller, start time, task performed.
                sprintf('compressing/combining footer JS in checksum: `%1$s`', md5($html))
            );
        }
        return $html; // With possible compression having been applied here.
    }
protected function maybeCompressCombineFooterJs ( $ html ) { if ( ( $ benchmark = ! empty ( $ this -> options [ 'benchmark' ] ) && $ this -> options [ 'benchmark' ] === 'details' ) ) { $ time = microtime ( true ) ; } $ html = ( string ) $ html ; // Force string value. if ( isset ( $ this -> options [ 'compress_combine_footer_js' ] ) ) { if ( ! $ this -> options [ 'compress_combine_footer_js' ] ) { $ disabled = true ; // Disabled flag. } } if ( ! $ html || ! empty ( $ disabled ) ) { goto finale ; // Nothing to do. } if ( ( $ footer_scripts_frag = $ this -> getFooterScriptsFrag ( $ html ) ) /* e.g. <!-- footer-scripts --><!-- footer-scripts --> */ ) { if ( ( $ js_tag_frags = $ this -> getJsTagFrags ( $ footer_scripts_frag ) ) && ( $ js_parts = $ this -> compileJsTagFragsIntoParts ( $ js_tag_frags , 'foot' ) ) ) { $ js_tag_frags_all_compiled = $ this -> compileKeyElementsDeep ( $ js_tag_frags , 'all' ) ; $ html = $ this -> replaceOnce ( $ footer_scripts_frag [ 'all' ] , '%%htmlc-footer-scripts%%' , $ html ) ; $ cleaned_footer_scripts = $ this -> replaceOnce ( $ js_tag_frags_all_compiled , '' , $ footer_scripts_frag [ 'contents' ] ) ; $ compressed_js_tags = [ ] ; // Initialize. foreach ( $ js_parts as $ _js_part ) { if ( isset ( $ _js_part [ 'exclude_frag' ] , $ js_tag_frags [ $ _js_part [ 'exclude_frag' ] ] [ 'all' ] ) ) { $ compressed_js_tags [ ] = $ js_tag_frags [ $ _js_part [ 'exclude_frag' ] ] [ 'all' ] ; } else { $ compressed_js_tags [ ] = $ _js_part [ 'tag' ] ; } } // unset($_js_part); // Housekeeping. $ compressed_js_tags = implode ( "\n" , $ compressed_js_tags ) ; $ compressed_footer_script_parts = [ $ footer_scripts_frag [ 'open_tag' ] , $ cleaned_footer_scripts , $ compressed_js_tags , $ footer_scripts_frag [ 'closing_tag' ] ] ; $ html = $ this -> replaceOnce ( '%%htmlc-footer-scripts%%' , implode ( "\n" , $ compressed_footer_script_parts ) , $ html ) ; if ( $ benchmark ) { $ this -> benchmark -> addData ( __FUNCTION__ , compact ( 'footer_scripts_frag' , 'js_tag_frags' , 'js_parts' , 'cleaned_footer_scripts' , 'compressed_js_tags' , 'compressed_footer_script_parts' ) ) ; } } } finale : // Target point; finale/return value. if ( $ html ) { $ html = trim ( $ html ) ; } // Trim it up now! if ( $ benchmark && ! empty ( $ time ) && $ html && empty ( $ disabled ) ) { $ this -> benchmark -> addTime ( __FUNCTION__ , $ time , // Caller, start time, task performed. sprintf ( 'compressing/combining footer JS in checksum: `%1$s`' , md5 ( $ html ) ) ) ; } return $ html ; // With possible compression having been applied here. }
Handles possible compression of footer JS.

@since 140417 Initial release.

@param string $html Input HTML code.

@return string HTML code, after possible JS compression.
Handles possible compression of footer JS .