• Hi!
    I would like to integrate this jQuery library. I want to use the following cdn-address (https://cdn.rawgit.com/nnattawat/flip/v1.0.16/dist/jquery.flip.min.js). I use a child-theme.
    I have already included a jQuery-script successfully by adding the following code to my functions.php-file.

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

    Is the way to include a jQuery library the same as I did when I included my own script, but just changing /js/myscript.js to the cdn-address? Or is there a better way?

    I have read the relevant codex-page page, but it didn’t really help my understanding of the problem.

    Thanks!

Viewing 1 replies (of 1 total)
  • Yep, similar

    add_action( 'wp_enqueue_scripts', 'register_jquery' );
    function register_jquery() {
        wp_deregister_script( 'jquery' );
        wp_register_script( 'jquery', ( 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' ), false, null, true );
        wp_enqueue_script( 'jquery' );
    }

    I use the google cdn as they are big enough to be sticking around for a few years at least!

    The “deregister” command makes sure there is only one jquery library loaded

    Taken from here: https://www.paulund.co.uk/load-jquery-cdn-with-wordpress

Viewing 1 replies (of 1 total)
  • The topic ‘Integrate jQuery library to child-theme’ is closed to new replies.