Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9243503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:49:28+00:00 2026-06-18T08:49:28+00:00

I use the WP native function wp_enqueue_script() for all my script loading in both

  • 0

I use the WP native function wp_enqueue_script() for all my script loading in both WP front and back-end so it can handle duplicated calls to the same script and so on.

One of the issues is that other programmers don’t use this function and load their scripts directly from their code, which causes jQuery or jQuery-UI to be loaded twice, leading to a bunch of errors.

The other issue is that code not owned by me triggers an error and stops the execution of JavaScript beyond this point.

In short:

A Javascript error occurs in code not owned by me.
My code doesn’t execute due to that error.
I want my code to bypass that error and still execute.
Is there a way to handle these issues?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:49:29+00:00Added an answer on June 18, 2026 at 8:49 am
    function ShieldAgainThirdPartyErrors($) {
        // Code you want protect here...
    }
    
    // First shot.
    // If no error happened, when DOMContentLoaded is triggered, this code is executed.
    jQuery(ShieldAgainThirdPartyErrors);
    
    // Backup shot.
    // If third party script throw or provoke an unhandled exception, the above function 
    // call could never be executed, so, lets catch the exception and execute the code.
    window.onerror = function () {
    
        ShieldAgainThirdPartyErrors(jQuery);
    
        return true;
    }
    

    If you want pull the trigger of your gun twice just when necessary 😉 set a flag to signal that the first shot was successful and avoid the backup shot, I think that under some circumstances your first shot could be executed even third party code get in trouble and trigger the second shot.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Android can use .so file through JNI. The native function in C/C++ is bound
How can I send a managed object to native function to use it? void
I am trying to use the native PHP function to send a simple test
Is there anyway I can use native javascript to fire an event called onmove
can cassandra use multiple native secondary indexes when querying on mutiple indexed columns? using
Can I use a native method which returns a pointer? I used the following
I'm trying to write a function, that would use native openssl to do some
I am using PHP. I used to use native mysql function password() to store
I have a native api function which looks like: DWORD WINAPI WlanRegisterNotification( __in HANDLE
I need following namespaces to use native wpf property grid however, VS 2010 doesn't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.