renderedtext / render_async

render_async lets you include pages asynchronously with AJAX
https://rubygems.org/gems/render_async/
MIT License
1.08k stars 75 forks source link

JS scripts not loading synchronously #152

Open SathishSuresh-opex opened 1 year ago

SathishSuresh-opex commented 1 year ago

I have html.erb file, loading two scripts .

<script type='text/javascript' src='https://service.force.com/embeddedservice/5.0/esw.min.js'></script>
<script type='text/javascript'>
  console.log("window.embedded_svc...", window.embedded_svc);
</script>

embedded_svc is part esw.min.js file. I expect window.embedded_svc print object, but it's undefined.

This issue occurs only when I use render_async , it works well with regular render Note - I have added in initializers

RenderAsync.configure do |config|
  config.jquery = true # This will render jQuery code, and skip Vanilla JS code. The default value is false.
end

Why script is not loading synchronously ?

Bohdan079 commented 1 year ago

I have html.erb file, loading two scripts .

<script type='text/javascript' src='https://service.force.com/embeddedservice/5.0/esw.min.js'></script>
<script type='text/javascript'>
  console.log("window.embedded_svc...", window.embedded_svc);
</script>

embedded_svc is part esw.min.js file. I expect window.embedded_svc print object, but it's undefined.

This issue occurs only when I use render_async , it works well with regular render Note - I have added in initializers

RenderAsync.configure do |config|
  config.jquery = true # This will render jQuery code, and skip Vanilla JS code. The default value is false.
end

Why script is not loading synchronously ?

nikolalsvk commented 1 year ago

Are you also using Turbo or Turbolinks in the project? Here's how to configure it if you are: