Many websites include JavaScript at the bottom of the page, so that the script doesn't run before the page is loaded and visible. An example.

It would be nice for includeJS() to have a boolean parameter that when set to true includes the JavaScript at the bottom of the page instead of in the HEAD.

Submitted by D. Pelsmaeker on 6 March 2012 at 14:10

On 6 March 2012 at 14:37 Danny Groenewegen commented:

WebDSL allows embedding javascript anywhere in a page/template using the <script> tag, for example:

<script>
  var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>

On 6 March 2012 at 15:21 D. Pelsmaeker commented:

What you propose is a workaround, not a solution. A quick search on the internet reveals (1, 2) that the general consensus is that scripts should always be put last in the website's body (for performance reasons), which is a detail that WebDSL should abstract.

The only reason that you'd want to put a script somewhere else is when the script has to execute at exactly that point in the website's HTML, which is also not something includeJS() will do. It stubbornly puts the javascript in the HEAD. But this last thing might be better abstracted into an insertJS() function.


On 6 March 2012 at 15:56 Danny Groenewegen commented:

The script tag is indeed a workaround, includeJS in its current form has some problems, most importantly it's lacking the ability to specify order of includes and it doesn't work properly with ajax http://yellowgrass.org/issue/WebDSL/443.

Log in to post comments