scriptInclude - why?

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?

Maybe I'm wrong ...

I wrote that. It was to simplify rendering the CSS and JS links in the
doc head.

I've Stopped using it in favor of JSMin and a request context
decorator that does the sane thing as script include: collect paths if
js/CSS to render

One reason to continue to use it would be if you generated dynamic
JavaScript. But again, I dint do that.

I've blogged on the technique I use now to manage assets within
ColdBox instead of ScriptInclude.

The blog post also illustrates a new native ColdBox 3 method to manage
your CSS/JS!

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.

See here, "Put Scripts At The Bottom":

CSS on the other should always be in the head if possible.


The is exactly why I posted my solution. You have full control:

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.