script.js icon indicating copy to clipboard operation
script.js copied to clipboard

Support for data attributes

Open wesleymusgrove opened this issue 9 years ago • 8 comments

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?

wesleymusgrove avatar Aug 25 '14 18:08 wesleymusgrove

interesting... there's no way to do this currently... but i'm sure support to get it in wouldn't be too hard

ded avatar Aug 25 '14 22:08 ded

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

isocroft avatar Oct 16 '14 09:10 isocroft

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

isocroft avatar Jan 26 '15 11:01 isocroft

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?

ehoch avatar Apr 09 '15 15:04 ehoch

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 avatar Jun 30 '16 16:06 flushentitypacket

@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 avatar Jul 01 '16 10:07 amorey

@amorey Looks awesome, I'll check it out.

flushentitypacket avatar Jul 01 '16 16:07 flushentitypacket

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.

andreiglingeanu avatar Aug 19 '16 12:08 andreiglingeanu