简体   繁体   中英

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?

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

script["defer"] = true

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM