Stop requesting script loading in HTML file
P粉154798196
P粉154798196 2024-04-01 00:05:44
0
2
406

I'm trying to prevent scripts from loading as HTML on my WordPress site. In my HTML file I can see these two scripts:

<script type="0f1a6d7ca503db410c0d10c4-text/javascript" src='https://www.[-----------].se/wp-content/plugins/theme -my-login/assets/script/theme-my-login.min.js?ver=7.1.2' id='theme-my-login-js'></script>

<script type="0f1a6d7ca503db410c0d10c4-text/javascript" src='https://www.phpcnc.com [---------------------].se/wp-content /themes/guru/framework/js/public/jquery.smartresize.js?ver=5.5.2' id='jquery-smartresize-js '></script>

In public_html/wp-content/themes/guru/framework/register_public.php I can comment out the second script and set it in the above php /* */ to prevent it from being loaded into the HTML file:

/* wp_enqueue_script('jquery-smartresize', $template_uri.'/js/public/jquery.smartresize.js', array(), false, true); */

The first script is from a plugin that I want to use on a certain page, so I don't want to deactivate the plugin. I will be building an IF statement in the php file to exclude/include the plugin script from being loaded into the HTML based on the page URL.

My problem is that I can't find the php file that loads the first script into HTML, like I can for the second script. Searching via ssh in public_html I didn't find anything interesting or get many clicks. Can I add filter ads? What does the filter code look like? I guess it would be better to prevent wp_enqueue_script from executing rather than letting wp_enqueue_script then add a filter.

P粉154798196
P粉154798196

reply all(2)
P粉691958181

Actually, I have only used

if ( isset( $_SERVER['REQUEST_URI'] ) &&
strpos( $_SERVER['REQUEST_URI'], 'the/page/that/uses/the/scripts' ) === false ) 
{wp_dequeue_script( 'theme-my-login' );
}

I'm not calling the function SO_21097900...this doesn't work...I don't know where to put the function. If I put that function in the same php file, my site crashes.

P粉734486718

Yes, you can dequeue scripts where you don't need to

function SO_21097900() {
    wp_dequeue_script( 'theme-my-login' );
    wp_dequeue_script( 'jquery-smartresize' );
}

if ( isset( $_SERVER['REQUEST_URI'] ) &&
 strpos( $_SERVER['REQUEST_URI'], 'the/page/that/uses/the/scripts' ) === false ) {
    add_action( 'wp_enqueue_scrips', 'SO_21097900', 100 );
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!