javascriptsymfonyassetic

Symfony 2 - Assetic JavaScript compression causing errors


I'm trying to put a Symfony 2 app in production mode. It all runs fine except for the fact that the compressed single JavaScript file causes errors and makes the site unable to render correctly. I found this through the debug console on the browser:

Uncaught TypeError: undefined is not a function
Uncaught TypeError: Object [object Object] has no method 'treeview'

The first error refers to jQuery plug-ins The treeview refers to a plugin for jQuery which renders a tree like directory structure.

On the other hand, it all runs fine on dev mode cause it doesn't do the compression and it just includes every file one by one. Can someone help me on this one?


Solution

  • I've found a solution to this, it appears the issue is related to missing semi-colons. When something is the last statement in a js file a semi-colon isn't required however assetic just joins the files together and only adds a new line.

    Check the file which is being included just before the broken plugin javascript and make sure it ends with a semicolon.