• Hi there,

    I am running my installation on WP-ENGINE, they ban most of the useful plugins and the others for some reason don’t work. I am trying to speed up my site using the Google Insights guidelines. My site uses 18x .js files and the site takes ages to load.

    I wanted to combine the .js files into 1 file which will nearly half the loading speed. Using the code below I have managed to disable ALL* .js files and the page loads rapidly.

    function my_deregister_javascript()
    {
    wp_deregister_script( ‘jquery’ );
    wp_deregister_script( ‘layerslider_js’ );
    wp_deregister_script( ‘jquery_easing’ );
    wp_deregister_script( ‘transit’ );
    wp_deregister_script( ‘layerslider_transitions’ );
    wp_deregister_script( ‘jquery.easing’ );
    wp_deregister_script( ‘cookie’ );
    wp_deregister_script( ‘jquery.slider’ );
    wp_deregister_script( ‘efects’ );
    wp_deregister_script( ‘modernizr.custom’ );
    wp_deregister_script( ‘et_masonry’ );
    wp_deregister_script( ‘flexslider’ );
    wp_deregister_script( ‘superfish’ );
    wp_deregister_script( ‘tooltip’ );
    wp_deregister_script( ‘tabs’ );
    wp_deregister_script( ‘etheme’ );
    wp_deregister_script( ‘wc-add-to-cart-variation’ );
    }
    add_action( ‘wp_print_styles’, ‘my_deregister_javascript’, 101 );

    Next I created a new file called “custom.js”, I placed this into the js folder inside my theme. I copied ALL* the javascipt from the above files and placed it inside the custom.js

    I then called the js file with the following code

    function etheme_enqueue_custom_styles()
    {
    wp_enqueue_script(‘jquery’, get_template_directory_uri().’/js/custom.js’);
    }
    add_action( ‘wp_enqueue_scripts’, ‘etheme_enqueue_custom_styles’ );

    The js file does load when you visit the website but nothing works. Its as if the the custom.js was empty the code inside it isn’t being used. Please help

Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Manually* combine JavaScript’ is closed to new replies.