Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template scripts fail to run if "head script" is included with "defer" #228

Closed
panasyuk opened this issue Jan 29, 2021 · 1 comment · Fixed by #244
Closed

Template scripts fail to run if "head script" is included with "defer" #228

panasyuk opened this issue Jan 29, 2021 · 1 comment · Fixed by #244
Assignees

Comments

@panasyuk
Copy link

panasyuk commented Jan 29, 2021

There is a script in

SpreeBraintreeVzero.checkoutFormId = '#update-cart';
which initializes "PayPal Checkout" button on cart page. It fails with ReferenceError: Can't find variable: SpreeBraintreeVzero error if application's JS is included in head tag in deferred mode:

<%= javascript_include_tag 'spree/frontend/all', defer: true %>

That happens because the head script runs after DOM is loaded causing head JS to run after the template's script.

The same works for another script: https://github.com/spree-contrib/spree_braintree_vzero/blob/master/app/views/spree/checkout/payment/braintree_vzero/_three_d_secure.html.erb and it causes errors on Payment step.

@panasyuk
Copy link
Author

The issues are probably related to the problem:
#220
#83

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants