protected function getScriptJsAsync(array $tag_frag, $test_for_js = true)
    {
        if ($test_for_js && !$this->isScriptTagFragJs($tag_frag)) {
            return ''; // This script tag does not contain JavaScript.
        }
        if (preg_match('/\s(?:async|defer)(?:\>|\s+[^=]|\s*\=\s*(["\'])(?:1|on|yes|true|async|defer)\\1)/ui', $tag_frag['script_open_tag'], $_m)) {
            return 'async'; // Yes, load this asynchronously.
        } // unset($_m); // Just a little housekeeping.

        return ''; // Unable to find a TRUE `async|defer` attribute.
    }
protected function getScriptJsAsync(array $tag_frag, $test_for_js = true)
    {
        if ($test_for_js && !$this->isScriptTagFragJs($tag_frag)) {
            return ''; // This script tag does not contain JavaScript.
        }
        if (preg_match('/\s(?:async|defer)(?:\>|\s+[^=]|\s*\=\s*(["\'])(?:1|on|yes|true|async|defer)\\1)/ui', $tag_frag['script_open_tag'], $_m)) {
            return 'async'; // Yes, load this asynchronously.
        } // unset($_m); // Just a little housekeeping.

        return ''; // Unable to find a TRUE `async|defer` attribute.
    }
protected function getScriptJsAsync ( array $ tag_frag , $ test_for_js = true ) { if ( $ test_for_js && ! $ this -> isScriptTagFragJs ( $ tag_frag ) ) { return '' ; // This script tag does not contain JavaScript. } if ( preg_match ( '/\s(?:async|defer)(?:\>|\s+[^=]|\s*\=\s*(["\'])(?:1|on|yes|true|async|defer)\\1)/ui' , $ tag_frag [ 'script_open_tag' ] , $ _m ) ) { return 'async' ; // Yes, load this asynchronously. } // unset($_m); // Just a little housekeeping. return '' ; // Unable to find a TRUE `async|defer` attribute. }
Get script JS async|defer value from a JS tag fragment.

@since 140417 Initial release.

@param array $tag_frag    A JS tag fragment.
@param bool  $test_for_js Defaults to a TRUE value.
If TRUE, we will test tag fragment to make sure it's JavaScript.

@return string The script JS async|defer value (if possible); else an empty string.
Get script JS async|defer value from a JS tag fragment .