reduxframework / redux-framework

Redux is a simple, truly extensible options framework for WordPress themes and plugins!
http://redux.io
Other
1.73k stars 582 forks source link

DEVS! HELP US TEST ASAP. #1337

Closed dovy closed 10 years ago

dovy commented 10 years ago

Hey WordPress devs. As if our last release wasn't enough, I just reduced load time of the panel by up to 300%! I need you to help me test ASAP.

\ It's been merged into master **

Grab it. Tell us if you have problems. I don't think you will though. Did I mention, this work will dramatically help us get groups out too? Oh yea. That's forthcoming.

If you can, donate to the effort (https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=N5AD7TSH8YA5U). Some of us have bills to pay and we're spending way too much time making your dev life easier.

Some have asked what we did differently?

We made the JavaScript on-demand. Traditionally we initialized every field in the panel on load. This took a lot of time. Certain JS functions (like the WP color picker, editor, ace_editor, etc) took a LONG time to load. By doing it the way we are, only the fields visible at any time are initialized. As you traverse your panel fields that are newly visible get initialized. In this way you load the full panel without having to launch javascript for fields you never see or use. I think you're users will b every VERY happy.

Please test this hard. Every field. GO!

tpaksu commented 10 years ago

it says "redux is not defined" on the chrome dev tools javascript console?

kprovance commented 10 years ago

You of all people should know better than to leave one liners that really tell us nothing.

dovy commented 10 years ago

Heh. More details please? Maybe a config gist?

tpaksu commented 10 years ago

Hey kevin, hey dovy, I downloaded the latest version and integrated to my test system, I compared the latest barebone-config.php with my custom config.php, and they were the same except my custom values, I think any of the fields in my config are initializing the "redux" variable (not the "$.redux" one). where do you initialize this variable? Since it's a javascript issue, and my sections config file is not a complicated one, I thought this info will be enough.

Here's the error log of mine:

Uncaught ReferenceError: redux is not defined field_media.js?ver=1402465855:13
Uncaught ReferenceError: redux is not defined field_switch.js?ver=1402465855:13
Uncaught ReferenceError: redux is not defined field_select.js?ver=1402465855:6
Uncaught ReferenceError: redux is not defined field_button_set.js?ver=1402465855:10
Uncaught ReferenceError: redux is not defined field_gallery.js?ver=1402465855:8
dovy commented 10 years ago

Something is off in your files. We don't initialize a $.redux variable now. The redux variable is the localized variable used by all js within Redux.

Sounds like you still have old files. ;)

tpaksu commented 10 years ago

Ok, I'll try again :) but the variable isn't $.redux, it's only "redux" as in "redux.field_objects".

2014-06-11 9:57 GMT+03:00 Dovy Paukstys notifications@github.com:

Something is off in your files. We don't initialize a $.redux variable now. The redux variable is the localized variable used by all js within Redux.

Sounds like you still have old files. ;)

— Reply to this email directly or view it on GitHub https://github.com/ReduxFramework/redux-framework/issues/1337#issuecomment-45708132 .

tpaksu commented 10 years ago

I deleted all the files in the redux admin folder, downloaded the latest ZIP from this repo, unzipped it, just copied ReduxCore and codestyles folder, index, uninstall, license.txt, class file, reduxframework.php file (they'll be enough I guess), and still getting the same errors on the javascript console.

I'm using dev mode = true (unminified sources). I modified the barebones config to suit my needs.

kprovance commented 10 years ago

The redux variable is set by the localize in the core. If you 'view source' on your options panel, somewhere you should see the line var redux = followed by a long json string. If you are not seeing this, then that might be part of the problem. Like Dovy said, make a gist of your config so one of us may try it.

kprovance commented 10 years ago

FWIW, if I comment out the line wp_enqueue_script( 'redux-js' ); // Enque the JS now in the core, it's reproducible. I have to assume for whatever reason, the resource is not appearing in your panel. Gotta find out why that is.

ghost commented 10 years ago

I've this problem in my chrome console:

Uncaught ReferenceError: redux is not defined field_switch.js?ver=1402483131:13 Uncaught ReferenceError: redux is not defined field_button_set.js?ver=1402483131:10 Uncaught ReferenceError: redux is not defined field_multi_text.js?ver=1402483131:6 Uncaught ReferenceError: redux is not defined field_slider.js?ver=1402483131:6 Uncaught ReferenceError: redux is not defined field_image_select.js?ver=1402483131:8 Uncaught ReferenceError: redux is not defined field_media.js?ver=1402483131:13 Uncaught ReferenceError: redux is not defined field_editor.js?ver=1402483131:13 Uncaught ReferenceError: redux is not defined field_spinner.js?ver=1402483131:6 Uncaught ReferenceError: redux is not defined field_background.js?ver=1402483131:13 Uncaught ReferenceError: redux is not defined color-picker.js?ver=1402483131:10 Uncaught ReferenceError: redux is not defined field_color_gradient.js?ver=1402483131:10 Uncaught ReferenceError: redux is not defined field_select.js?ver=1402483131:6 Uncaught ReferenceError: redux is not defined field_typography.js?ver=1402483131:15 Uncaught ReferenceError: redux is not defined field_sorter.js?ver=1402483131:12 Uncaught ReferenceError: redux is not defined field_ace_editor.js?ver=1402483131:6 Uncaught ReferenceError: redux is not defined field_import_export.js?ver=1402483131:6 Uncaught TypeError: Cannot read property 'switch' of undefined redux.js?ver=1402482581:429

What appened? Please, fix it fast. It's a BOOM for our code and development.

Thanks.

tpaksu commented 10 years ago

I can see the var redux definition, but it's placed after the field scripts. That might be the problem. On dev mode = true (BTW I didn't test the dev_mode=false), the redux localized data script is loaded after the enqueued field scripts.

kprovance commented 10 years ago

Interesting, @tpaksu, mine is loaded before the field javascripts. That might be a clue. Wake up, @dovy, join us! ;-)

tpaksu commented 10 years ago

I changed

wp_register_script(
                    'redux-js',
                    self::$_url . 'assets/js/redux' . $min . '.js',
                    $depArray,
                    filemtime( self::$_dir . 'assets/js/redux' . $min . '.js' ),
                    -> true
                );

to false, for letting the script load itself in the head, the problem is gone.

But the question is: is it the proper way to solve this ?

kprovance commented 10 years ago

Do me a favour, undo that, and on line 422ish, change

add_action( 'admin_enqueue_scripts', array( $this, '_enqueue' ));

to

add_action( 'admin_enqueue_scripts', array( $this, '_enqueue' ), 1 );

I want to see if it makes a difference.

tpaksu commented 10 years ago

nope, still has it.

kprovance commented 10 years ago

Hmmm, ok. I'd keep what you've done for now. If Dovy gives it his stamp of approval, I'll make it permanent. The change was all about speed improvement. I don't know if putting all that in the head compromises that. Dovy might tho. :)

tpaksu commented 10 years ago

Well, I just read that : registering "redux-js" as a dependency to the field scripts' enqueue lines, is the proper way to solve problems like this. That might change the loading order of "redux-js" in the footer.

kprovance commented 10 years ago

So, that is to say, go into each field's php, add 'redux-js' to the js enqueue's dependency array, so the var redux stuff loads before the field js? That will cause it to load before the field js?

tpaksu commented 10 years ago

I got curious about it, and found this post and gave me that idea:

http://wordpress.stackexchange.com/a/114502/14452

kprovance commented 10 years ago

Can you set the enqueue back to true, and add that dep to one of the fields you are using and see if it works? Thing is, mine is still loading before the field js (trying to figure out why). If it works for you, we might have a proper solution :)

tpaksu commented 10 years ago

Yes it worked! The first field loaded and giving error (in my setup) was a media field, I added the "redux-js" dependency to it, and all errors are gone. But we need to apply to all of fields because we won't know which fields will be the first one to load.

wp_enqueue_script(
                    'redux-field-media-js',
                    ReduxFramework::$_url . 'inc/fields/media/field_media' . Redux_Functions::isMin() . '.js',
                    array( 'jquery', 'wp-color-picker', 'redux-js' ),
                    time(),
                    true
                );
kprovance commented 10 years ago

You sir, get the 'Redux contributor of the day' award!

I concur, especially since the redux builder allows user to pick and choose their fields now, adding the dep to each one is mandatory.

I'll start making changes. Thank you, dude. :D :D :D

tpaksu commented 10 years ago

You're welcome :)

kprovance commented 10 years ago

Okay @tpaksu and @gianbalex, I pushed v.3.3.0.6, which adds the redux js dep to every field that requires it. Please let me know if the update works out for each of you. :)

simrandeep commented 10 years ago

I think performance has improved now. Checking it further.

tpaksu commented 10 years ago

Yes, it's working now @kprovance .

kprovance commented 10 years ago

Awesome. My up at 4 am coz the neighbors dog won't shut up has not been in vain! :) @simrandeep, it's a huge difference. And I run Windows, so to be able to say that is a big deal. ;-)

edcousins commented 10 years ago

Hi Kevin/Dovy,

Only issue I've found so far is that upon saving theme options, occasionally the Font Weight / Style in typography field will be removed?

Much quicker though, great work!

kprovance commented 10 years ago

@edcousins, if you want, open a new ticket and include your typography field(s). The new js might be playing havok with it.

kprovance commented 10 years ago

Fixed, I believe. Closing.

wpexplorer commented 10 years ago

Shit this is fast! I'll get testing, sick!

kprovance commented 10 years ago

Cha-ching, AJ. ::evil grin::

maheshwaghmare commented 8 years ago

@kprovance I'm still facing the issue Uncaught ReferenceError: redux is not defined

I'm working on localhost and used plugin Redux Vendor Support to enqueue the local assets.

As @tpaksu suggested ( https://github.com/ReduxFramework/redux-framework/issues/1337#issuecomment-45726818 ). I was made changes on locahost i.e.

'dev_mode' => false,

and

File: \framework\core\enqueue.php - Line - 278

// Redux JS
//*****************************************************************
wp_register_script(
                    'redux-js',
                    ReduxFramework::$_url . 'assets/js/redux' . $this->min . '.js',
                    $depArray,
                    $this->timestamp,
                    false
);

Set false in both changes. And it works.

My current redux version is - 3.5.8.1

What was the wrong with my current setup. Or any other issue.

maheshwaghmare commented 8 years ago

Now, Update it with version 3.5.8.4. Still facing same issue. I'm working on localhost by turning off internet. Its internet issue or any other?