Reputation: 8415
How can I define the load order of javascript assets in the Play framework when I load scripts in sub templates?
In my index.scala.html
I pull in jQuery:
<script src="@routes.Assets.at("javascripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
and in my sub template I pull in a script that depends in jQuery:
<script src="@routes.Assets.at("javascripts/myScript.js")" type="text/javascript"></script>
However, myScript.js
is being loaded before 'jquery-1.7.1.min.js'.
Any advice?
Upvotes: 1
Views: 384
Reputation: 1051
You should pass the script as a parameter to your index.scala.html
.
But I recommend RequireJS. RequireJS enables you to use lazy loading.
Upvotes: 3