kasparsd / minit

A WordPress plugin to combine CSS and Javascript files.
GNU General Public License v2.0
286 stars 46 forks source link

inline scripts loading before the minified script #72

Closed lineshjose closed 8 years ago

lineshjose commented 8 years ago

Hi, I really like your plugin.

A lots of inline script are loading before the minified script, that included jquery, in footer so I getting "jQuery is not defined" error, because of this some inline script not working.

How can i fix this issue

kasparsd commented 8 years ago

@lineshjose you need to exclude jquery from being processed by Minit:

add_filter( 'minit-exclude-js', function( $handles ) {
    $exclude = array(
        'jquery',
    );

    return array_merge( $handles, $exclude );
} );
lineshjose commented 8 years ago

Thanks. I've excluded jquery from Minit and it loading in header now and everything is working :)

But it lowered the google's pagespeed score because of "render-blocking JavaScript". Is there any way to load jquery in footer before the all other scripts?

kasparsd commented 8 years ago

Minit already does that but your page is probably calling jQuery somewhere before the footer scripts are loaded. You should remove all the inline scripts that are called before Minit instead.

anishjajodia commented 8 years ago

It still is giving me the error. @kasparsd

Could you help me out?