Since there is no deferred option for:
<asset:javascript src="custom_view_script.js"/>
What else can be used, outside of resource plugin, to place view specific script right before the closing body tag and without declaring it globally in layout?
I do know about:
<asset:deferredScripts/>
but that only handles on page script and not includes.
The most simple way is using site mesh.
In your layout you need to put
At the end of the body.
Then in the page you will do something like this:
Notice that the content tag (script) is any text that you specify, but to refer to that content from sitemesh you prepend "page." to it.
However, be careful because sitemesh properties are not cumulative, I mean, if you put two sections with content tag="script" only the last one will be used.
If you need that, as I usually do, you can accomplish it by using a custom TagLib that slightly modifies the SitemesTagLib:
Now you can keep the g:pageProperty in your layout but you would do this in your pages:
That should collect all the content you put in different views and templates and then show it up in your final html where your g:pageProperty tag is.