YouTubeBuzz.com - Buy real YouTube video views safe & cheap

Support Forum

Register To login to our Support Forum use your member’s username/password combination.

Not a member? Create a free club account here.

Welcome Guest 

Show/Hide Header

Welcome Guest, posting in this forum requires registration.





Pages: [1]
Author Topic: Enqueue slider to stop it loading on ALL pages?
Ed
Newbie
Posts: 2
Permalink
Post Enqueue slider to stop it loading on ALL pages?
on: February 8, 2012, 22:39
Quote

Guys is there a way to stop thethe image slider script from loading on every page?

It's currently the slowest thing on my website because you have to load the java every page, can this be enqueued?

TheThe
Administrator
Posts: 143
Permalink
Post Re: Enqueue slider to stop it loading on ALL pages?
on: February 10, 2012, 19:57
Quote

This is a common place in WordPress - you can't control this, as for now. However, once loaded the script is cached by browser and you do not really loose time.

Bryce
Newbie
Posts: 2
Permalink
Post Re: Enqueue slider to stop it loading on ALL pages?
on: May 15, 2012, 16:05
Quote

sure you can, its documented all over the web. now that said, something about your plugin doesn't allow it to be deregistered, which is extemely frustrating (as is the fact that you force the load of your own jQuery).

Here's a link to Justin Tadlock's post about it. http://justintadlock.com/archives/2009/08/06/how-to-disable-scripts-and-styles

EDIT:
Ok, I've figured out how to deregister the script, and will now work on using a conditional statement to only load it on pages that use the slider. Here is the deregister code.

// Deregister Plugin Scripts
add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );

function my_deregister_javascript() {
	$handles = array( 'slider-ui');

	foreach($handles as $myplugin){
	wp_deregister_script($myplugin);
	}
}

I still don't understand why my attempted override of your loading of an old version of jQuery doesn't work. Quite frustrating really.

EDIT 2
Ok, so I've got it working with a conditional statement to load only on the homepage (where my slider is). I had to adjust the code I posted above to accommodate the if statement, and I'm sure there is a way to use both, but at this moment, I'm happy with this.

// Deregister Plugin Scripts
add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );

function my_deregister_javascript() {
	if ( !is_front_page() ) {
		wp_deregister_script('slider-ui');
	}
}
Pages: [1]
Mingle Forum by cartpauj
Version: 1.0.34 ; Page loaded in: 0.697 seconds.

Subscribe to WP Tips & Hacks Newsletter