Support » Plugin: Modernizr for WordPress » Script handle not in plugin domain

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author Ramoonus

    (@ramoonus)

    dear Gal
    it`s used on init, which is how I normally enqueue without adding it in a wrapper

    That’s not the point. Each enqueued script is given a handle, and yours is given an unconventional handle that should be changed.

    Plugin Author Ramoonus

    (@ramoonus)

    i disagree
    i use it like this so modernizr is only loaded once, never twice

    Why would an enqueued script be loaded twice? That’s precisely the point of a handle. If you enqueue the same handle again, the second one is ignored.

    If you’re talking about some theme developer already loading modernizr via another handle, that’s something they should resolve. Using a plugin for this can be comfortably based on the assumption that there is no conflict with this particular script.

    Where have you seen the script loaded twice? In what situation?

    Plugin Author Ramoonus

    (@ramoonus)

    when it conflicts, it means another version of modernizr is loaded
    that is an unwanted situation

    i haven`t heard of this happening yet

    So what’s the problem? Just change the handle to “modernizr” and your plugin will be compliant and most likely prevent conflicts, if any.

    You can actually use this code to remove any conflict before enqueuing your own version:

    if ( wp_script_is( 'modernizr', 'enqueued' ) ) {
        wp_dequeue_script( 'modernizr' );
        wp_deregister_script( 'modernizr' );
    }
    Plugin Author Ramoonus

    (@ramoonus)

    pushinmg 2.8.4 right now with the improvement
    thank you

    i didn`t know about this function (script is)

    Gal Baras

    (@galbaras)

    I see a new version is now available, but the PHP code is the same as 2.8.3, and the Github mirror for the plugin still shows 2.8.3 as the current version.

    Plugin Author Ramoonus

    (@ramoonus)

    yes it`s in trunk now

    spending more time on it when 3.3 comes around

    The changelog shows this as part of 2.8.4, and there’s a new version, but no change.

    What’s 3.3?

    Plugin Author Ramoonus

    (@ramoonus)

    I forgot to tag 2.8.4

    version 3.3 contains modernizr 3.3

    @ramoonus you are still enqueuing your script with the handle ‘wp_enqueue_scripts’, which is still in the core name space.

    Please change it to ‘modernizr’, which is what you are trying to override.

    The full code should be:

    function rw_modernizr() {
    
    		// @since 2.8.4
    		if ( wp_script_is( 'modernizr', 'enqueued' ) ) {
    			wp_dequeue_script( 'modernizr' );
    			wp_deregister_script( 'modernizr' );
    		}
    
    		wp_enqueue_script( 'modernizr', plugins_url('/js/modernizr-custom.js', __FILE__), array('jquery'), '2.8.4', false );
    }
    add_action( 'wp_enqueue_scripts', 'rw_modernizr' );

    Still waiting for the update…

    Plugin Author Ramoonus

    (@ramoonus)

    i don`t have much time for version 3.3 currently since I have to build the modernizr version myself
    which can lead to more bugs

    This changes ONE WORD – the script handle. Right now, you’re checking for one script, but enqeueing another, and you’re using a name in the WP core name space.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Script handle not in plugin domain’ is closed to new replies.