I got a custom JS-File called index.js. In this file I put my jQuery plugins/extensions like a cookie Plugin or a highlightning Plugin.
With YII_DEBUG=true everythig is doing fine, but when I turn off YII_DEBUG (for production) the jQuery Plugins in the index.js are not regognized anymore, while the index.js itself is loaded from the client.
So I ran into several "missing function" errors.
My first hint went into the fact, that instead of jquery.js jquery.min.js gets loaded in production-environment. But as the jquery.min.js has the same functionality as the jquery.js I would not expect any problems.
Yes, thats what I thought also, but it seems to make a difference.
To point out what I did to examine the problem:
When YII_DEBUG is set to false, jQuery extensions seems not to be loaded. The extensions/plugins resides in a separated index.js file, which is loaded by the client as the jquery.min.js also.
When using those jQuery extensions, FireBug reports "missing function …".
That only occurs in YII_DEBUG = false. With YII_DEBUG=true everything is going well.
I did 3 things:
Used scriptmap as mentioned above and verified it with FB. Looked like the jquery.js from google was loaded. But the "missing function …" error was still there.
Used scriptmap to load the jquery.js in my asset-folder. I know, thats something we shouldn’t do, but for debugging its ok, I guess. Nevertheless, it drops the same error-message as mentioned in 1.
Modified /web/js/packages.php and changed the ‘jquery.min.js’ in the first package in ‘jquery.js’, so that independent of YII_DEBUG on or off it’s always loads the jquery.js. Well, that solves the “missing function…” problem.
I know, that is dirty and not wanted under any circumstances.
Maybe important:
The jquery.js and jquery.min.js (depending on the YII_DEBUG state) are always loaded before my custom index.js.
For me it looks like YII handles jQuery-extensions in a different way when in DEBUG=false.
I would like to have some advice if it makes sense to open a bug-report.
I will try to do a testcase on a fresh application with nothing but a startpage and some JavaScript.
I don’t know if loading jquery.js followed by jquery.min.js would be worse than just loading jquery.js twice, but it could be worth it checking for multiple inclusions.
@samdark: Indeed there was another scriptMap besides the one in the config/main.php, regarding to the jquery.js. I removed that one temporarily as the one in the main.php. Unfortunaly without success.