Skip to content

Commit

Permalink
Add script at the end of body instead of head
Browse files Browse the repository at this point in the history
Problem is that especially in firefox the script is loaded before the
dom content is loaded
See FriendlyCaptcha/friendly-challenge#20
  • Loading branch information
DanieliMi committed Apr 28, 2021
1 parent 2bff025 commit 4660d76
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 15 deletions.
6 changes: 3 additions & 3 deletions view/frontend/layout/contact_index_index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<script src="IMI_FriendlyCaptcha::js/vendor/friendly-challenge/widget.module.js" type="module" async="true" />
</head>
<body>
<referenceContainer name="form.additional.info">
<block class="IMI\FriendlyCaptcha\Block\Frontend\FriendlyCaptcha" name="imi_friendly_captcha_widget" after="-"
template="IMI_FriendlyCaptcha::imi_friendly_captcha.phtml"
ifconfig="imi_friendly_captcha/frontend/enabled"/>
</referenceContainer>
<referenceContainer name="before.body.end">
<block class="Magento\Framework\View\Element\Template" template="IMI_FriendlyCaptcha::imi_friendly_captcha_js.phtml" name="friendly_captcha_js" ifconfig="imi_friendly_captcha/frontend/enabled"/>
</referenceContainer>
</body>
</page>
6 changes: 3 additions & 3 deletions view/frontend/layout/customer_account_create.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<script src="IMI_FriendlyCaptcha::js/vendor/friendly-challenge/widget.module.js" type="module" async="true" />
</head>
<body>
<referenceContainer name="form.additional.info">
<block class="IMI\FriendlyCaptcha\Block\Frontend\FriendlyCaptcha" name="imi_friendly_captcha_widget" after="-"
template="IMI_FriendlyCaptcha::imi_friendly_captcha.phtml"
ifconfig="imi_friendly_captcha/frontend/enabled_create" />
</referenceContainer>
<referenceContainer name="before.body.end">
<block class="Magento\Framework\View\Element\Template" template="IMI_FriendlyCaptcha::imi_friendly_captcha_js.phtml" name="friendly_captcha_js" ifconfig="imi_friendly_captcha/frontend/enabled"/>
</referenceContainer>
</body>
</page>
6 changes: 3 additions & 3 deletions view/frontend/layout/customer_account_forgotpassword.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<script src="IMI_FriendlyCaptcha::js/vendor/friendly-challenge/widget.module.js" type="module" async="true" />
</head>
<body>
<referenceContainer name="form.additional.info">
<block class="IMI\FriendlyCaptcha\Block\Frontend\FriendlyCaptcha" name="imi_friendly_captcha_widget" after="-"
template="IMI_FriendlyCaptcha::imi_friendly_captcha.phtml"
ifconfig="imi_friendly_captcha/frontend/enabled_forgot" />
</referenceContainer>
<referenceContainer name="before.body.end">
<block class="Magento\Framework\View\Element\Template" template="IMI_FriendlyCaptcha::imi_friendly_captcha_js.phtml" name="friendly_captcha_js" ifconfig="imi_friendly_captcha/frontend/enabled"/>
</referenceContainer>
</body>
</page>
6 changes: 3 additions & 3 deletions view/frontend/layout/customer_account_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<script src="IMI_FriendlyCaptcha::js/vendor/friendly-challenge/widget.module.js" type="module" async="true" />
</head>
<body>
<referenceContainer name="form.additional.info">
<block class="IMI\FriendlyCaptcha\Block\Frontend\FriendlyCaptcha" name="imi_friendly_captcha_widget" after="-"
template="IMI_FriendlyCaptcha::imi_friendly_captcha.phtml"
ifconfig="imi_friendly_captcha/frontend/enabled_login" />
</referenceContainer>
<referenceContainer name="before.body.end">
<block class="Magento\Framework\View\Element\Template" template="IMI_FriendlyCaptcha::imi_friendly_captcha_js.phtml" name="friendly_captcha_js" ifconfig="imi_friendly_captcha/frontend/enabled"/>
</referenceContainer>
</body>
</page>
6 changes: 3 additions & 3 deletions view/frontend/layout/sendfriend_product_send.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<script src="IMI_FriendlyCaptcha::js/vendor/friendly-challenge/widget.module.js" type="module" async="true" />
</head>
<body>
<referenceContainer name="form.additional.info">
<block class="IMI\FriendlyCaptcha\Block\Frontend\FriendlyCaptcha" name="imi_friendly_captcha_widget" after="-"
template="IMI_FriendlyCaptcha::imi_friendly_captcha.phtml"
ifconfig="imi_friendly_captcha/frontend/enabled_sendfriend" />
</referenceContainer>
<referenceContainer name="before.body.end">
<block class="Magento\Framework\View\Element\Template" template="IMI_FriendlyCaptcha::imi_friendly_captcha_js.phtml" name="friendly_captcha_js" ifconfig="imi_friendly_captcha/frontend/enabled"/>
</referenceContainer>
</body>
</page>
8 changes: 8 additions & 0 deletions view/frontend/templates/imi_friendly_captcha_js.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
/**
* Copyright © iMi digital GmbH, based on work by MageSpecialist
* See LICENSE for license details.
*/
/** @var \Magento\Framework\View\Element\Template $block */
?>
<script src="<?= $block->getViewFileUrl('IMI_FriendlyCaptcha::js/vendor/friendly-challenge/widget.module.js')?>" type="module" async></script>

0 comments on commit 4660d76

Please sign in to comment.