script.js
script.js copied to clipboard
Support for data attributes
Is it possible to pass in data-* attributes when loading a script?
For example, Pinterest's pinit.js accepts a data-pin-hover
attribute:
script type="text/javascript" src="//assets.pinterest.com/js/pinit.js" data-pin-hover="true"
How could this be achieved using script.js?
interesting... there's no way to do this currently... but i'm sure support to get it in wouldn't be too hard
I could work on this data-* idea for the $script script tag... It's really neat! and again, it could also apply to script tags created and appended as deps by $script
Already built in support for data-* attributes on the script tag. However, i erroneously pushed this feature under a wrong issue title (#76). So i will push again under a new issue title and see how it goes from here
Any chance we could consider merging this? It's needed for Pinterest on our site as @wesleymusgrove mentioned. @isocroft can I check out the code you have for this?
Somewhat related, I'd like to be able to set the crossorigin
attribute--maybe the feature could support setting arbitrary attributes?
EDIT: Looks like there's an open issue already: https://github.com/ded/script.js/issues/40
@flushentitypacket I've been working on a variant of script.js
that's optimized for modern browsers (most notably it supports load failure callbacks). If you're interested we could add it there via a crossorigin: true
flag:
https://github.com/muicss/loadjs
@amorey Looks awesome, I'll check it out.
Anything new on that one? I can come up with a quick pull request for that one, if any of you guys won't mind.