0

I am developing a website in WordPress 4.3. In this we use more than 20 plugins. The CSS and jQueries of every plugin are loaded on every page.

My question is: how can I optimize the styles and jQueries in that way the required styles and jQueries are included on each page.

I am trying wp_enque_script() but cannot get success. Also I am going to do that, include CSS and jQuery on each page that they required. But I think this is not a better way.

URL of my website is: http://omtut.com/

1 Answer 1

1

You can try to use conditional logics. Ex: if you need to include "homepage.js" only on home page, you may try

if(is_home()){
    // use wp_enque_script() function to include the said js file
}

Likewise you can include only the required js/css files in each page.

Sign up to request clarification or add additional context in comments.

2 Comments

But all files are loaded through wp_head(). So how i handle this
wp_enque_script() function is used in functions.php, so open up the functions.php file on your theme and try to optimize those js/css files there. And make sure to remove the entries including those js/css files initially. ( may be plugins or on your theme code )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.