wordpress jQuery causing failed chrome audit tool – render blocking

0 Votes
    869 Views

I’m working on my theme, and test in here and there in chrome audits to see how it’s looking as I’m working on the site.

I noticed that when using jQuery as a dependent of a script, it fails chrome audit and says that the script is render blocking. Is there another way or another option i should put in my enqueue script to stop this from happening.

My code. (Shortened for easier reading)

FUNCTIONS.PHP

function site_assets() {    
  wp_enqueue_script('force-easy-scroll', get_template_directory_uri() . '/js/force.min.js', array('jquery'), null, true);   
}

add_action('wp_enqueue_scripts', 'site_assets');

RENDERED HTML

    <!-- END MAIN SITE CONTENT -->
    <footer>

    </footer>
    <script type='text/javascript' src='http://smtg-new/wp-content/themes/SMTG_THEME/js/force.min.js'></script>

    </body>

</html>

CHROMES AUDIT
jquery fails chrome audit in wordpress

Now for testing purposes, I have 4 scripts that I’m enqueuing now that all reside right before the closing body tag. All depending on jQuery. I’ll combine them later on. But none of those are showing as render blocking, considering there at the bottom of the page.

How can I get wordpress’s built in jQuery to not be render blocking? It’s putting a pretty big hit in time and it’s frustrating. I rather not dequeue it’s own version of jQuery and use mine. I don’t do any fancy stuff with it so I don’t need the latest version. There version is totally fine.

1

Answers


Please signup or login to answer this question.