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

Support for defer attribute on <script> tags #506

Closed
mpatzner opened this Issue Oct 20, 2016 · 2 comments

Comments

Projects
None yet
4 participants
@mpatzner

mpatzner commented Oct 20, 2016

"This Boolean attribute is set to indicate to a browser that the script is meant to be executed after the document has been parsed, but before firing DOMContentLoaded."

Source: https://developer.mozilla.org/de/docs/Web/HTML/Element/script

This would be a nice-to-have feature. I currently work around this missing feature by adding a script tag manually without calling the js() helper. However, then the cachebuster plugin won't work.

@fourpixels

This comment has been minimized.

Show comment
Hide comment
@fourpixels

fourpixels Nov 17, 2016

Just opened this repo to report this issue :)
I've already hacked mine with something like:

// kirby/kirby/component/js.php
public function tag($src, $async = false, $defer = false) {

...

return html::tag('script', '', array(
    'src'   => url($src),
    'async' => $async,
    'defer' => $defer
));

Works like a charm, but I wouldn't rely on hardcoding my copy, as I won't be able to properly upgrade in future. Otherwise - great job!

fourpixels commented Nov 17, 2016

Just opened this repo to report this issue :)
I've already hacked mine with something like:

// kirby/kirby/component/js.php
public function tag($src, $async = false, $defer = false) {

...

return html::tag('script', '', array(
    'src'   => url($src),
    'async' => $async,
    'defer' => $defer
));

Works like a charm, but I wouldn't rely on hardcoding my copy, as I won't be able to properly upgrade in future. Otherwise - great job!

@bastianallgeier bastianallgeier added this to the 2.5 milestone Nov 18, 2016

@lukasbestle lukasbestle modified the milestones: 2.5.2, Future Jul 1, 2017

@lukasbestle lukasbestle self-assigned this Jul 2, 2017

@lukasbestle

This comment has been minimized.

Show comment
Hide comment
@lukasbestle

lukasbestle Jul 2, 2017

Member

This feature is now available on the develop branch. Instead of adding a third param, you can now pass an array of totally custom attributes (like ['defer' => true]) as the second param.

Member

lukasbestle commented Jul 2, 2017

This feature is now available on the develop branch. Instead of adding a third param, you can now pass an array of totally custom attributes (like ['defer' => true]) as the second param.

@lukasbestle lukasbestle closed this Jul 2, 2017

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