yii2-minify-view
                                
                                 yii2-minify-view copied to clipboard
                                
                                    yii2-minify-view copied to clipboard
                            
                            
                            
                        Google Recaptcha does not load using yii2-minify-view
Hi rmrevin,
at first: thanks a lot for your wonderful extension. It is great !
unfortunately i stumbled upon a problem:
I use the https://github.com/himiklab/yii2-recaptcha-widget to display an captcha on my page.
This widget loads a .js file directly from google: https://github.com/himiklab/yii2-recaptcha-widget/blob/master/ReCaptcha.php#L109
When activating your extension, the .js file stops being loaded ! I have no Idea why this happens. This is my configuration - which is very standard:
[
            'class' => '\rmrevin\yii\minify\View',
            'enableMinify' => true,
            'concatCss' => true,
            'minifyCss' => true,
            'concatJs' => true,
            'minifyJs' => true,
            'minifyOutput' => true,
            'webPath' => '@web',
            'basePath' => '@webroot',
            'minifyPath' => '@webroot/minify',
            'jsPosition' => [\yii\web\View::POS_END],
            'forceCharset' => 'UTF-8',
            'expandImports' => true,
            'compressOptions' => ['extra' => true],
        ],
There is no AssetBundle to ignore since the file gets loaded from google. I also tried to do this:
  'excludeFiles' => [
                '//www.google.com/recaptcha/api.js?hl=de&render=explicit&onload=recaptchaOnloadCallback',
          
            ],
but without success.
Do you have any ideas ?
Thanks a lot in advance !
hi @thyseus , the problem is not in min js, is in jsPosition,
if you change POS_END to POS_HEAD
It will work.
@metola This does work indeed. Thanks a lot !
Is it possible to only use POS_HEAD on a specific controller & action (where the captcha is), but POS_END everywhere else? Javascript "feels" te be more performant to the end user if it is loaded as late as possible.
Same problem, jsPosition not solve it.
ReCaptcha.php added file by this code
const JS_API_URL = '//www.google.com/recaptcha/api.js';
$view->registerJsFile(
    self::JS_API_URL . '?' . $arguments,
    ['position' => $view::POS_END, 'async' => true, 'defer' => true],
    'recaptcha-api'
);
but some reason extension not ignoring it
Come across the same issue here. Not a fan of the fix t change the POS as _end is best practice for JS but doing so does fix the issue.
@thyseus @wa1kb0y put this in your config:
 'excludeFiles' => [
     'recaptcha-api'
]
@n30fly it works, ty