WordPress.org

Ready to get started?Download WordPress

Forums

Lazy Load
Option to not enqueue JS by page? (3 posts)

  1. WebEndev
    Member
    Posted 1 year ago #

    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/

  2. alexphelps3
    Member
    Posted 1 year ago #

    +1 for this.

  3. Lea Cohen
    Member
    Posted 7 months ago #

    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' );

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.