Make different sites on multisite reference same script

Hi this is what I did to solve it:

add_filter( 'script_loader_src', 'change_src' );
add_filter( 'style_loader_src', 'change_src' );

function change_src( $url )
{   
    if( is_admin() ) return $url; // Don't filter admin area
    return str_replace( site_url(), 'www.mysite.com/mydefaultnetworksite', $url );
}

I’m using both those filters because I want it to apply to script and stylesheet urls. The function just looks for the site url, rips it out and replaces it with a hardcoded version of the url I want all the sites scripts / stylesheets to point to.

I opted for the first site in the multisite, but it could be any 🙂