Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In you build.scala file, add all your dynamic js files to requireJS, like for example : </p> <pre><code>val main = play.Project(appName, appVersion, appDependencies).settings( requireJsShim += "main-normal.js" requireJs += "main-normal.js", requireJs += "main-admin.js", ) </code></pre> <p>Then when you start play using 'play start' , requireJS will treat these individual files as modules, which you can see in the console output as :</p> <pre><code>{ appDir: "javascripts", baseUrl: ".", dir:"javascripts-min", mainConfigFile: "main-normal.js", modules: [ {name: "main-normal"}, {name: "main-admin"} ] } </code></pre> <p>It will then start resolving dependencies for those js files, and in your site, inspect using firebug/chrome dev tools and in the network tab, it will reflect the changes, do a fresh reload/delete the cache in your browser to see the changes.</p> <p>Also, for performance improvements, i suggest that you use the r.js file instead of default rhino compiler as suggested in the play framework docs, you can download it here : <a href="https://raw.github.com/jrburke/r.js/master/dist/r.js" rel="noreferrer">https://raw.github.com/jrburke/r.js/master/dist/r.js</a></p> <p>copy the file into your project folder and add the following line to your build.scala above the requireJsShim line : </p> <pre><code> requireNativePath := Some("r.js") </code></pre> <p>so, in effect your build.scala file should be : </p> <pre><code>val main = play.Project(appName, appVersion, appDependencies).settings( requireNativePath := Some("r.js"), requireJsShim += "main-normal.js" requireJs += "main-normal.js", requireJs += "main-admin.js", ) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload