Support » Plugin: Lazy Load » Option to not enqueue JS by page?

  • Awesome plugin!

    Would it be possible to add an option in a future release that would allow the user to exclude the wp_enqueeu_script of the JS files on a particular page or pages?

    I have modified lazy-load.php to not load on the front page, but my mods will of course be overwritten on the next plugin update.

    Thanks

    http://wordpress.org/extend/plugins/lazy-load/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Alex Phelps

    (@alexphelps3)

    +1 for this.

    The solution I found was dequeuing the scripts, in my theme.

    So if you have control over your theme (i.e you built your own, and can modify it to your heart’s content), you can add this to your functions. php:

    function mop_enqueue_site_scripts () {
        global $wp_scripts;
    	if (is_home()){
    		if ( in_array ( 'wpcom-lazy-load-images', $wp_scripts -> queue ) ) {
    			wp_dequeue_script('wpcom-lazy-load-images');
    		}
    		if ( in_array ( 'jquery-sonar', $wp_scripts -> queue ) ) {
    			wp_dequeue_script('jquery-sonar');
    		}
    	}
    }
    
    add_action ( 'wp_enqueue_scripts', 'mop_enqueue_site_scripts' );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Option to not enqueue JS by page?’ is closed to new replies.