Forcing a javascript file to be loaded at the end in symfony

Very often, we  want javascript files to be loaded after another. For instance, you may your files containing jquery functions to be loaded after the main jquery.js file to avoid the typical error:

$ is not defined

use_javascript (and addJavascript) accepts a ‘position’ parameter to deal with this. Position can be ‘first’ or ‘last’. For instance:

<?php use_javascript('file-you-want-to-load-at-the-end.js', 'last')?>
  1. No comments yet.

  1. No trackbacks yet.