Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught ReferenceError: xxx is not defined #69

Closed
krokodile opened this issue Jan 19, 2012 · 4 comments
Closed

Uncaught ReferenceError: xxx is not defined #69

krokodile opened this issue Jan 19, 2012 · 4 comments
Labels

Comments

@krokodile
Copy link

We have following js structure - all js are loaded to user at once, except page-specific initializers ( e.g. init.main.js , init.subscription.js, init.product_list.js ). So usual structure looks like :

{% compressed_js 'all' %}
<script src='init.product_list.js'></script> 

init.product_list.js tries to call functions from 'all', but cannot do it, as compressed_js encapsulates everything inside

 (function($){...}).call(this)

Demonstration -http://jsfiddle.net/TwSqe/11/

Is it possible to solve this issue without modifying code ?

@cyberdelia
Copy link
Member

Without modifying code, just add init.product_list.js in your 'all' group.
Or declare your function as global when needed.

@krokodile
Copy link
Author

init.product_list.js - is specific for 'products' page, other pages have it's own initializers( init.offers.js for example ), so it's impossible to add init.* functions to 'all' group.

My point is - (function($){...}).call(this) - can damage working code ( which works without PIPELINE=True ). Why it's needed and hard coded? I suppose it should be possible to disable such behavior in settings.

@cyberdelia
Copy link
Member

This is for performance, avoiding unexplicit globals : http://dev.opera.com/articles/view/efficient-javascript/?page=2#avoidglobal

@cyberdelia
Copy link
Member

I will add documentation about this, see #73.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants