addScript.js 642 B

123456789101112131415161718192021222324252627
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. module.exports = function(src) {
  6. function log(error) {
  7. (typeof console !== "undefined")
  8. && (console.error || console.log)("[Script Loader]", error);
  9. }
  10. // Check for IE =< 8
  11. function isIE() {
  12. return typeof attachEvent !== "undefined" && typeof addEventListener === "undefined";
  13. }
  14. try {
  15. if (typeof execScript !== "undefined" && isIE()) {
  16. execScript(src);
  17. } else if (typeof eval !== "undefined") {
  18. eval.call(null, src);
  19. } else {
  20. log("EvalError: No eval function available");
  21. }
  22. } catch (error) {
  23. log(error);
  24. }
  25. }