Call callback on tracking script load error

This commit is contained in:
Joshua Flowers 2020-05-19 18:19:19 +03:00
parent 5adaa5667e
commit b7bca44beb
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 );
}
}
}