Can anyone tell me why using scriptInclude to load javascripts is a
good idea?
If it's took keep their location secret ... I'm thinking that it
really doesn't matter. Because once it loads into the clients browser
it's viewable - right?
One issue I have with the way ColdBox handles some of this is that it
puts js files in the html head. It's my understanding that absent some
specific need, current best practices put js (both files and in-line)
just before the close of the body tag. Modern browsers block rendering
until all js has downloaded.
You're right Aaron. You might want to note that recommendation
specifically on your page, and mention that the CB3 approach doesn't
do that, and neither does the JSMin plugin.
There are a couple of other enhancements to this strategy that I think
could also help. First, the ability to add inline js and js, as well
as files. Second, an argument to the add methods for js and js files
to specifically request that they go in the collection intended for
the head, instead of in the body collection like they do by default.
Third, rendering methods you can just call, instead of hand coding
that in each layout. In the similar thing I built for a (non-CB) app,
there are renderHeadContent and renderEndContent methods, to output
all the accumulated css and js for the head section, and the same for
the end-of-body stuff.