Merge pull request #26549 from woocommerce/fix/26493-error-handling

Call callback on tracking script load error
This commit is contained in:
Vedanshu Jain 2020-05-19 21:09:06 +05:30 committed by GitHub
commit 12ff70fb14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -115,7 +115,14 @@ class WC_Site_Tracking {
// Callback after scripts have loaded.
script.onload = function() {
if ( 'function' === typeof callback ) {
callback();
callback( true );
}
}
// Callback triggered if the script fails to load.
script.onerror = function() {
if ( 'function' === typeof callback ) {
callback( false );
}
}
}