Detecting javascript in a Yii webapp

8 views
Skip to first unread message

booyah

unread,
Jun 4, 2009, 9:06:42 PM6/4/09
to Web Optimizer
I've added Web Optimizer to my Yii webapp. I've included the require
and finish() in the main layout (./protected/views/layouts/main.php)
and the CSS is detected and handled by the optimizer, but the
javascript is not. I'm thinking it's because the javascript is
autoloaded into the view, unlike the CSS which is referenced in the
view, and this is happening after the optimizer gets the the head of
the page, because debugging shows $this->initial_files only contains
the CSS.

So perhaps I'm not implementing correctly for Yii? I can't find any
information specific to Yii besides in your changelog for 4.9 it says
something about Yii autoload support being fixed.

FYI I'm using Yii 1.0.5.

booyah

unread,
Jun 4, 2009, 9:17:50 PM6/4/09
to Web Optimizer
I managed to solve my issue after I found this:
http://code.google.com/p/web-optimizator/issues/detail?id=12

Nikolay Matsievsky

unread,
Jun 5, 2009, 5:24:07 AM6/5/09
to Web Optimizer
Problem with any JavaScript located outside the document head is that
is can contain any number of document.write calls. So we can't just
'glue' it -- we need something smarter.
One approach is to add a number of known widely used JavaScript
applications (i.e. Google Analytics or AdWords) that can be handled in
an investigated way. This approach is implemented in 0.5alpha (SVN).
Also we can add a number of additional instructions to <body> to
indicate for Web Optimizer that some scripts can be merged safely. Or
merged in a known way. Or something else. Thinking about it.
Reply all
Reply to author
Forward
0 new messages