freakydev
freakydev

Reputation: 153

Where to include js files ,in actions(controller) or view (zf2)?

Hi all im working on zf2, I was allways including js files from the view pages. But i can include it in the controller also using appendscript(). Which is the best method according to mvc ?

Upvotes: 0

Views: 235

Answers (1)

Marek
Marek

Reputation: 7433

Javascript works with view output - the view knows, what javascript is needed to make everything work. And the view might not be directed to the browser, other view media might be used. For this reason, I prefere adding javascript from inside view.

Upvotes: 1

Related Questions