Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to add arbitrary attributes to the generated <script> tag #16

Closed
vpavkin opened this issue Jan 25, 2017 · 3 comments
Closed

Comments

@vpavkin
Copy link

vpavkin commented Jan 25, 2017

For example, it can be useful to add defer/async attribute to optimize page load time.

@vmunier
Copy link
Owner

vmunier commented Jan 25, 2017

Hi,

We could add an additional htmlAttributes: Html parameter with a default value, so that the new library version remains compatible with existing code.

Parameters of src/main/twirl/scalajs/scripts.scala.html would look like:

@(projectName:    String,
  assets:         String => String,
  resourceExists: String => Boolean
  resourceExists: String => Boolean,
  htmlAttributes: Html = Html("")
)

Usage would be:

@scalajs.html.scripts(
  projectName = "client",
  name => s"/assets/$name",
  name => getClass.getResource(s"/public/$name") != null,
  Html("defer async newAttr=newValue")
)

What do you think?

@vpavkin
Copy link
Author

vpavkin commented Jan 25, 2017

looks perfectly fine to me :) Sorry, haven't had time to make a pr yet :(

@vmunier
Copy link
Owner

vmunier commented Jan 25, 2017

No worries, I'll include the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants