0

General Scala-JS page building advice needed. Most of the examples seem to be of the pattern where the main into which your single page application will go is between the tags in a landing page html file. How do you handle the need to insert something in the meta area of the dom? Do I need to render my landing page dynamically from the server to accomplish this? My specific need is to inject a script tag into the meta area of an already defined static html page. I'm using scalajs-react.

bjenkins001
  • 141
  • 1
  • 9

1 Answers1

0

Generally you will want a server-rendered "root page" for the SPA. This allows you to dynamically compute proper cache busting file names for your script and stylesheet tags and to easily manage the cache expiration of the root page. Also, for proper html5 push state support you'll want to serve that page at every URL, which is easily done with a server side route.

easel
  • 3,982
  • 26
  • 28
  • But right now my ReactComponentB objects are working at the level of a div inside of the body of my landing or root page. Should / Can I work at the level of the html tag so that I can control the meta information page-by-page? Right now I don't see how to step outside of that inside-the-body div to inject meta information. – bjenkins001 Aug 26 '15 at 19:30
  • I wouldn't. Something has to bootstrap react, scalajs, etc, and to do that you need to cache bust the urls for your -jsdeps, -fullopt, etc. The play-scala-js stuff pretty much "just works", although it's a huge dependency for such a simple page. – easel Aug 26 '15 at 19:37