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

cvars.js is empty? #7

Open
codecowboy opened this issue Jan 4, 2015 · 2 comments
Open

cvars.js is empty? #7

codecowboy opened this issue Jan 4, 2015 · 2 comments

Comments

@codecowboy
Copy link

Is cvars.js actually used?

I can see the localisation of the script in wpoa_init_frontend_scripts_styles() but the file is empty when it reaches the browser even though the wpoa_cvars JS object is populated. Is this normal for WordPress script 'localisation' ? I thought the file gets populated before it hits the browser. I'm using Chrome devtools

@perrybutler
Copy link
Owner

It's a blank file, solely for satisfying the localization which seems to require a handle to a registered .js script:

http://codex.wordpress.org/Function_Reference/wp_localize_script

I never looked into that further. I also don't know if it's supposed to populate the .js script with vars, but from what I have experienced it outputs a dynamic <script> block right after the script itself. Maybe wpoa_cvars can be localized via the wp-oauth.js script instead...I'll try that out later.

@codecowboy
Copy link
Author

As you say, the variable actually gets injected into the page within a <script> block but in this case it is doing that before the file is included. So you may as well inject it into another js file and save an http request. If you need to include it later, you could use the in_footer argument set to true.

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

No branches or pull requests

2 participants