Recent Topics

1 Apr 12, 2014 00:39    

I have no use for jquery-ui at all and it's kind of large (around-400kb) . How can I NOT load jquery-ui ?

2 Apr 13, 2014 13:20

Hi @tilqicom

Well, I'm not sure if all the features of the back-office will be available if you don't load the jquery-ui, but if you need it, you just have to comment/delete the right lines in the blogs/inc/_core/_template.funcs.php file.

Go to the function require_js and you will find this array:


$js_aliases = array(
		'#jquery#' => 'jquery.min.js',
		'#jquery_debug#' => 'jquery.js',
		'#jqueryUI#' => 'jquery/jquery.ui.all.min.js',
		'#jqueryUI_debug#' => 'jquery/jquery.ui.all.js',
	);

Lines 808 and 809 must be removed to avoid loading jquery-ui. Note: the line numbering corresponds to the current stable release. It may vary on different versions.

Regards!

3 Apr 13, 2014 16:56

I wasnt talking about backoffice, I was talking about frontend. Why does jquery-ui load in my skin anyway, what's the use ?
I don't think hacking the core is a good idea.
WP has a counterpart hook "wp_dequeue_script" to disable the enqueued scripts. Isn't there such a hook available ?

4 Apr 19, 2014 19:55

Of course, I agree that the core should remains untouched as long as we can, but if you need a specific behavior that is not supported by the software, then hacking is the only way. I think that b2evo have not such a thing like "wp_dequeue_script", but looking a little deeper, I found at least two better ways to do not load jquery.ui when is not needed. But, both of them have pros and cons.

1) Comment/delete the line 1053 at blogs/inc/_core/_template.funcs.php require_js( '#jqueryUI#', $relative_to ); (Pro: the back-office is not affected at all - Con: is different than the first one I suggested, but at the end, it's also a core hack).
2) Do not include require_js_helper( 'colorbox', 'blog' ); in the skin that you're currently using. Pro: it's not a hack - Con: you loose the colorbox feature.

As you see, the jquery.ui library is loaded when the colorbox feature is supported by the skin (also on init_datepicker_js, but it's way less probable that the skin include a call to that function). So, I will use this post to make two requests: 1) evaluate that jquery.ui is loaded only when it's actually needed, and 2) evaluate the implementation of a feature like wp_dequeue_script.

Thanks.

5 Apr 21, 2014 15:17

I see. So I'll try simply commenting out or not including colorbox line as that triggers jquery UI.
Why does colorbox trigger jQuery UI anyway ? :D It doesnt make sense. And yeah it'd be great if we could dequeue javascript or css files that are enqueued.
Thanks

@mgsolipa wrote earlier:

2) Do not include require_js_helper( 'colorbox', 'blog' ); in the skin that you're currently using. Pro: it's not a hack - Con: you loose the colorbox feature.

As you see, the jquery.ui library is loaded when the colorbox feature is supported by the skin (also on init_datepicker_js, but it's way less probable that the skin include a call to that function). So, I will use this post to make two requests: 1) evaluate that jquery.ui is loaded only when it's actually needed, and 2) evaluate the implementation of a feature like wp_dequeue_script.

Thanks.


Form is loading...