coffeescripticed-coffeescript

Using defer attribute in iced-coffeescript


I'm trying to insert a script tag from an iced-coffeescript file. I wish to specify the script's defer attribute, but the coffeescript compiler doesn't like that I'm trying to define something called defer, since it's a keyword.

Is there any solution that allows me to do the following:

script = document.createElement('script')
script.type = 'text/javascript';
script.defer = true
script.async = true
script.src = "//initrode.com/scripts/myscript.js"

Or am I stuck ande cannot use this attribute?


Solution

  • Found the answer on the project's GitHub pages. You simple have to replace the line with:

    script["defer"] = true