« HOME

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

By Nacho Martín on 23 February 2010

Very often, we want in symfony 1.x 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')?>

Written by @nacmartin

blog comments powered by Disqus

» ALL POSTS