so including library this
var start = function() { ... } var loadscript = function() { script = document.createelement('script'); script.type = 'text/javascript'; script.src = 'https://whatever.com/js?callback=start'; document.body.appendchild(script) } window.onload = loadscript; as see, set function called "start" callback library. trouble if minify file, function isn't called start anymore.
i tried this, not work.
script.src = 'https://whatever.com/js?callback=' + start.name; how can programatically add name of function src attribute?
edit
i using rails 4, , assets in coffeescript, not think can use named function declarations.
most minifiers won't collapse global pointers. if had window.start (although not super recommended have many generic global names that).
or, justify it, window.myapp.myutil.start
another thing keep in mind anonymous functions don't have name properties, though you've assigned variable. you'll need add function declaration.
window.start = function start() { // stuff }
Comments
Post a Comment