Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the version of underscorejs used

I'm building a widget which would be used in different eCommerce sites.

As i'm using underscorejs library, i need to see if underscorejs exists in the parent site and if so what version.

If underscore is already defined in the site and if the version matches with the one i used. I would inturn use their own defined underscore and not make a CDN call to load underscorejs for my widget.

like image 921
Ashwath Govind Avatar asked Dec 31 '25 14:12

Ashwath Govind


1 Answers

You can easily check that with the following

if (!window._ || window._.VERSION !== '1.7.0') {
  // Load underscore from CDN
}
like image 177
idbehold Avatar answered Jan 03 '26 05:01

idbehold



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!