Symfony 2 - Assetic JavaScript compression causing errors
Asked Answered
E

1

6

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?

Extortion answered 28/2, 2012 at 11:3 Comment(2)
Are you using yui compressor or closure compiler? Try the one which you haven't used and see if that worksWilks
Do the Symfony logs show any YUI errors? (assuming you're using YUI for compression)Mariandi
R
14

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.

Royster answered 4/6, 2012 at 1:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.