Search code examples
javascriptangularjsinternet-explorerinternet-explorer-8es5-shim

Check in javascript if es5-shim.js is loaded or not? That's for ie8


Is there a way to define if

https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.1.0/es5-shim.js

from

https://cdnjs.com/libraries/es5-shim

is loaded or not?

For AngularJS you can check in javascript:

if(!window.angular){
//not loaded
}

What's the proper way of doing that for shim?

Thank you.


Solution

  • Try

    <!--[if lt IE 9]>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.1.0/es5-shim.js"></script>
    <script>String.prototype.trim || document.write('<script src="/js/es5-shim.js"><\/script>')</script>
    <![endif]-->
    

    or let me know if it isn't work.