Skip to content

deferred / async script loading with getBlock #400

@edzillion

Description

@edzillion

Hi

I notice that when I use getBlock to render my script block it adds defer to the script tag:

<%- @getBlock('scripts').add((@site.scripts).concat(@document.scripts or [])).toHTML() %>

to

<script defer="defer" src="libs/jquery-1.8.3.js"></script><script defer="defer" src="libs/modernizr.custom.94543.js"></script><script defer="defer" src="js/main.js"></script><script defer="defer" src="js/homepage.js"></script>

so is there a way to control this? I want the homepage.js script to be rendered without defer.

also, somewhat related:

I had a problem with the docpad gist plugin because it was blocking my UI scripts from running, but when I modified the script to render with the async attribute the gists mysteriously disappear.

opts.content = content.replace(/<gist>/g, "<script src='https://gist.github.com/").replace(/<\/gist>/g, ".js'></script>");

to

opts.content = content.replace(/<gist>/g, "<script async src='https://gist.github.com/").replace(/<\/gist>/g, ".js'></script>");

the rendered script tags look fine: <script async="" src="https://gist.github.com/4348144.js"></script>

tested in chrome and ff and both say they support the async attrib. webpagetest suggests that the calls are made to the github servers just the same

any ideas? thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions