How does the concatenation feature of $wp_scripts in Admin support URLs instead

  • Unknown's avatar

    Modified file path:wordpress/wp-includes/script-loader.php

    //Enable jQuery to load from a CDN URL.
    $scripts->add( 'jquery-core', "/wp-includes/js/jquery/jquery$suffix.js", array(), '3.7.1' );
    //Replace with the following code.
    $scripts->add( 'jquery-core', "https://code.jquery.com/jquery-3.7.1.min.js", array(), '3.7.1' );

    Modified file path:wordpress/wp-admin/load-scripts.php

    $path = ABSPATH . $wp_scripts->registered[ $handle ]->src;
    $out .= get_file( $path ) . "n";
      $path =  $wp_scripts->registered[ $handle ]->src;
      if (strstr($path, 'code.jquery.com')) {
            $out .=  trim(file_get_contents($path)) . "n";
      }else{
            $path = ABSPATH . $path;
            $out .= get_file( $path ) . "n";
      }


    Result: After changing src to url, jquery-core cannot be found in the merged list for loading.
    Question: How should I modify it to merge the content of jQuery from the url?
    Attempted: Trying to push jquery-core into the array($load[]) also did not work.

    if ( !in_array( 'jquery-core', $load ) ) {
        $load[] = 'jquery-core';
    }


  • Unknown's avatar

    The issue was found to be related to the sequence of JavaScript concatenation. After adjusting the order, everything is working fine now.

  • Unknown's avatar

    Hello!

    Thank you for reaching out to the free support forums for websites hosted on WordPress.com. While your site is not hosted with us, we’re here to guide you in the right direction for assistance.

    In the future, since you’re using the open-source version of the WordPress platform, which operates differently from what we provide on WordPress.com, you can find help at the community forums here:

    https://wordpress.org/support/forum/how-to-and-troubleshooting/

    The community members in the open-source forum are well-versed in these matters and are in the best position to offer support.

    I hope this information helps guide you in the right direction.

  • The topic ‘How does the concatenation feature of $wp_scripts in Admin support URLs instead’ is closed to new replies.