render_async icon indicating copy to clipboard operation
render_async copied to clipboard

JS scripts not loading synchronously

Open SathishSuresh-opex opened this issue 3 years ago • 2 comments

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 ?

SathishSuresh-opex avatar Nov 22 '22 12:11 SathishSuresh-opex

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 avatar Mar 14 '23 19:03 Bohdan079

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

nikolalsvk avatar Mar 15 '23 18:03 nikolalsvk