Search code examples
javascriptjquerystylusgetscript

$.getScript rangeerror?


I'm using stylus to render some code into CSS on the clientside.

If I include the stylus.min.js file in my initial load everything works fine.

However because stylus is quite large I would like to delay loading that file until it's needed and grab it with jquery's 1.8.2 $.getScript().

Doing so gives me this error:

RangeError: stylus:947:26
   943|       &[data-aaa="1"]
   944|           margin-top 2em
   945|       &[data-bbb="1"]
   946|           transition 1s
   947|           margin-top -2em
---------------------------------^

Maximum call stack size exceeded


    at f.visit (http://f264bc8tf77nkh.cloudfront.net/static/1akh96ita/ace/stylus-min.js?_=1465163994282:4:26233)
    at i.visit (http://f264bc8tf77nkh.cloudfront.net/static/1akh96ita/ace/stylus-min.js?_=1465163994282:4:17594)
    at f.visit (http://f264bc8tf77nkh.cloudfront.net/static/1akh96ita/ace/stylus-min.js?_=1465163994282:4:26106)
    at i.visit (http://f264bc8tf77nkh.cloudfront.net/static/1akh96ita/ace/stylus-min.js?_=1465163994282:4:17594)
    at f.visit (http://f264bc8tf77nkh.cloudfront.net/static/1akh96ita/ace/stylus-min.js?_=1465163994282:4:26106)
    at i.visit (http://f264bc8tf77nkh.cloudfront.net/static/1akh96ita/ace/stylus-min.js?_=1465163994282:4:17594)
    at f.visit (http://f264bc8tf77nkh.cloudfront.net/static/1akh96ita/ace/stylus-min.js?_=1465163994282:4:26106)
    at i.visit (http://f264bc8tf77nkh.cloudfront.net/static/1akh96ita/ace/stylus-min.js?_=1465163994282:4:17594)
    at f.visit (http://f264bc8tf77nkh.cloudfront.net/static/1akh96ita/ace/stylus-min.js?_=1465163994282:4:26106)
    at i.visit (http://f264bc8tf77nkh.cloudfront.net/static/1akh96ita/ace/stylus-min.js?_=1465163994282:4:17594)

Is it that there is some limitation on scripts that are loaded via getScript that I can turn off?

Thanks.

Loading code:

load = function(templateName, callback) {
  if (_.str.endsWith(templateName, '.js')) {
    var url = '//' + settings.cdn + '/static/' + settings.assetsTime +'/' + templateName

    $.getScript(url, function(data, textStatus, jqxhr) {
      if (callback) callback()
    });
    return
  }
}

I load many other files with this same code and it works fine.


Solution

  • NVM the problem was in minification.