Set concatenated JavaScript files as async/defer #128

Closed
StephenBrown opened this Issue Jan 21, 2013 · 5 comments

Comments

Projects
None yet
3 participants
@StephenBrown

I needed a way to set the concatenated js file as async. My quick, easy solution was to put a property in the config file (js.type = async).

@drublic

This comment has been minimized.

Show comment
Hide comment
@drublic

drublic Jan 21, 2013

Member

Sounds like this could be a property for project.properties too.

Member

drublic commented Jan 21, 2013

Sounds like this could be a property for project.properties too.

@roblarsen

This comment has been minimized.

Show comment
Hide comment
@roblarsen

roblarsen Jan 21, 2013

Member

I'll add that to the 1.0 branch.

If anyone else wants it before that lands (a couple of weeks) it's a simple fix.

Add the attribute here ( https://github.com/h5bp/ant-build-script/blob/master/build.xml#L629 ):

<var name="replaceRegex" value="&lt;script src='\1/${scripts.sha}.js\' aync &gt;&lt;/script&gt;" />

for a configurable solution, add an empty string to a property called async in default.properties

and then add a value to it in project.properties

async = async

Then spit that out in the above line of the build script

<var name="replaceRegex" value="&lt;script src='\1/${scripts.sha}.js\' ${aync} &gt;&lt;/script&gt;" />
Member

roblarsen commented Jan 21, 2013

I'll add that to the 1.0 branch.

If anyone else wants it before that lands (a couple of weeks) it's a simple fix.

Add the attribute here ( https://github.com/h5bp/ant-build-script/blob/master/build.xml#L629 ):

<var name="replaceRegex" value="&lt;script src='\1/${scripts.sha}.js\' aync &gt;&lt;/script&gt;" />

for a configurable solution, add an empty string to a property called async in default.properties

and then add a value to it in project.properties

async = async

Then spit that out in the above line of the build script

<var name="replaceRegex" value="&lt;script src='\1/${scripts.sha}.js\' ${aync} &gt;&lt;/script&gt;" />
@StephenBrown

This comment has been minimized.

Show comment
Hide comment
@StephenBrown

StephenBrown Jan 22, 2013

For clarity, defer could be included in the property name:
async-defer =
or
scripts.async-defer =

For clarity, defer could be included in the property name:
async-defer =
or
scripts.async-defer =

@roblarsen

This comment has been minimized.

Show comment
Hide comment
@roblarsen

roblarsen Jan 23, 2013

Member

I can add defer as well, but... why? I guess it can't hurt, but the scripts are already at the bottom of the page so it's kind of belt and suspenders- unless I'm missing something (entirely possible)

Member

roblarsen commented Jan 23, 2013

I can add defer as well, but... why? I guess it can't hurt, but the scripts are already at the bottom of the page so it's kind of belt and suspenders- unless I'm missing something (entirely possible)

@roblarsen

This comment has been minimized.

Show comment
Hide comment
@roblarsen

roblarsen Jan 23, 2013

Member

as above. closed in the 1.0 branch. I added defer and async as separate options.

Member

roblarsen commented Jan 23, 2013

as above. closed in the 1.0 branch. I added defer and async as separate options.

@roblarsen roblarsen closed this Jan 23, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment