Site icon Hip-Hop Website Design and Development

Dequeue / Deregister script and change it with a brand new plugin

I believe I’ve learn a dozen posts about dequeuing and deregistering scripts, however I have never been in a position to make it work correctly in my scenario.

My scenario:
The "uListing" plugins are a part of the "HomePress" actual property theme. There’s a difficulty with the AJAX search the place, in the event you sort in solely a specific single digit after which pause, it freezes the entire web page. I consider it will depend on the outcomes which might be discovered by that single digit (the offending digits are totally different on totally different websites), however I used to be in a position to replicate the issue on the supplier’s personal demo web site with 5 totally different digits. The issue is because of a loop that by no means completes, as a result of outcomes discovered. We are able to escape that loop with a easy return, and it really works as desired.

However now I am attempting to interchange their script with my very own, inside one other plugin. (In order that it does not get overwritten by theme or plugin updates.)

Their plugin hundreds the script like so:

wp_enqueue_script('stm-search-form-category', ULISTING_URL . '/property/js/frontend/stm-search-form-category.js', array('vue'), ULISTING_VERSION, true);

My plugin makes an attempt to override it this manner:

operate fixUlisting() {
    wp_dequeue_script( 'stm-search-form-category' );
    wp_deregister_script( 'stm-search-form-category' );
    wp_enqueue_script( 'stm-search-fix', '/wp-content/plugins/ulisting-search-fix/stm-search-fix.js' );
}
add_action( 'wp_enqueue_scripts', 'fixUlisting', 100 );

I consider these steps are in the fitting order(?). I consider I am utilizing precedence (100) and site (true) accurately(?). I can see that my new script is loaded within the Community tab. I’ve tried together with the unique script’s dependency (vue). I’ve tried re-using the unique deal with, however resorted to utilizing a unique deal with primarily based on posts I learn (neither works). I clear the server cache, use totally different model numbers (or clean, or null) together with the ‘mum or dad’ plugin’s authentic model quantity, then re-test in a recent incognito browser window each time. Regardless of all of that, the unique script continues to be controlling the AJAX search ends in each occasion.

What do I have to do to make sure that my script is used as a substitute of the unique? Any assist can be vastly appreciated.