• Hello,

    I’m working on a website. I was asked to change the include-names of all css and js files. The purpose is to delete the parameters so the files are cacheable. I was wondering how to go about doing this in WordPress?

Viewing 8 replies - 1 through 8 (of 8 total)
  • You would have to find the enqueue statements in your functions.php file. You can find documentation for the enqueue functions for the style and scripts in the codex.

    Please don’t edit the functions.php file in your theme. Create a new one in your child theme. You can use the wp_dequeue function to uninstall the currently loaded styles and script.

    remove the script
    <?php wp_dequeue_script( $handle ); ?>

    remove style
    <?php wp_dequeue_style( $handle ) ?>

    install script
    <?php wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); ?>

    install style

    <?php wp_enqueue_style( $handle, $src, $deps, $ver, $media ); ?>

    for an example check out these functions in your functions.php file in your parent theme.

    Thread Starter SharkCityMan

    (@sharkcityman)

    Here’s an example of what’s in the functions.php file:

    function functions()
        {
            include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    
            require_once(THEME_FUNCTIONS . "/general-functions.php");
            //require_once(THEME_FUNCTIONS . "/image-cropping.php");
            require_once(THEME_FUNCTIONS . "/bfi_cropping.php");
            require_once(THEME_FUNCTIONS . "/ajax-search.php");
            require_once(THEME_CLASSES . "/wp-nav-custom-walker.php");
            require_once(THEME_FUNCTIONS . "/enqueue-front-scripts.php");
            require_once(THEME_FUNCTIONS . "/dynamic-styles.php");
    
            require_once(THEME_CLASSES . "/love-this.php");
            require_once(THEME_GENERATORS . '/sidebar-generator.php');
            require_once(THEME_FRAMEWORK . "/breadcrumbs/breadcrumbs.php");
            require_once(THEME_FRAMEWORK . "/tgm-plugin-activation/request-plugins.php");
            include_once (THEME_ADMIN_POST_TYPES . '/news.php');
            include_once (THEME_ADMIN_POST_TYPES . '/faq.php');
            include_once (THEME_ADMIN_POST_TYPES . '/portfolio.php');
    
            include_once (THEME_ACTIONS . '/header.php');
            include_once (THEME_ACTIONS . '/general.php');
            include_once (THEME_ACTIONS . '/post.php');
            include_once (THEME_ACTIONS . '/slideshow.php');

    Do I have to do a wp_enqueue_script for each css file and a wp_enqueue_style for each js file?

    Thread Starter SharkCityMan

    (@sharkcityman)

    Okay, so here’s what I did for a jquery.js file:

    function pinboard_theme_scripts(){
    
      	wp_enqueue_script('jquery', get_stylesheet_directory_uri() . 'js/jquery/jquery.js', array('jquery'));
    	}
    
    	add_action('wp_enqueue_scripts', 'pinboard_theme_scripts');

    Is this right?

    jquery is loaded by wordpress for you. You shouldn’t have to enqueue it.

    It is however loaded in non-conflict mode to keep you from having problems with other scripting libraries. You might want to check in the codex for a list of pre-installed scripts. Also, You might want to view documentation on using jquery in no-conflict mode.

    But, your example looks correct.

    Thread Starter SharkCityMan

    (@sharkcityman)

    Thank you for that. Here’s what I’m trying to do:

    there are still inclusdes with parameter:

    https://www.singleboerse.de/…i-lightbox/ilightbox-style.css?ver=4.2.2
    https://www.singleboerse.de/…ed-posts/css/default-style.css?ver=4.2.2
    https://www.singleboerse.de/…ugins/tablepress/css/default.css?ver=1.6
    https://www.singleboerse.de/…-includes/js/jquery/jquery.js?ver=1.11.2
    https://www.singleboerse.de/…es/js/jquery/jquery-migrate.js?ver=1.2.1
    https://www.singleboerse.de/…themes/jupiter-child/style.css?ver=4.2.2
    https://www.singleboerse.de/…t/themes/jupiter/js/plugins.js?ver=4.2.2
    https://www.singleboerse.de/…es/jupiter/js/theme-scripts.js?ver=4.2.2
    https://www.singleboerse.de/wp-includes/js/twemoji.js?ver=4.2.2 https://www.singleboerse.de/…es/js/jquery/jquery-migrate.js?ver=1.2.1

    Please remove the parameter so that the files are cachable.

    Can anybody help me understand what I need to do and how to do it?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    So, which theme are you using that’s loading all this stuff?

    Thread Starter SharkCityMan

    (@sharkcityman)

    Jupiter theme.

    Thread Starter SharkCityMan

    (@sharkcityman)

    Here’s one suggestion I found here: Fix Above-The-Fold Javascript and CSS

    I’ll leave this open for a couple more days to see if anybody wants to offer any other suggestions.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Change Include Names’ is closed to new replies.