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 async scripts #20

Closed
seehat opened this issue May 6, 2021 · 3 comments
Closed

Add async scripts #20

seehat opened this issue May 6, 2021 · 3 comments
Assignees
Labels
wontfix This will not be worked on

Comments

@seehat
Copy link

seehat commented May 6, 2021

Is there a way to output scripts with the async attribute?

If not can you add it?

@seehat seehat changed the title Add async scripts. Add async scripts May 6, 2021
@bnomei bnomei self-assigned this Jun 8, 2021
@bnomei
Copy link
Owner

bnomei commented Jun 8, 2021

the build in snippet has no support for that yet.
https://github.com/bnomei/kirby3-htmlhead/blob/master/snippets/htmlhead/script-js.php

but you could create your own snippet and just add its filename with to the plugins config array. like here but indead of htmlhead/script-js you could use your snippets filename.

TIP: thats how you can basically add anything to this plugin. snippets ftw. :D

@bnomei bnomei added the wontfix This will not be worked on label Jun 8, 2021
@seehat
Copy link
Author

seehat commented Jun 8, 2021

Ok thank you for your tip! I know this and thought that it would make sense in core, but it's ok for me, when it stays like this.

@bnomei
Copy link
Owner

bnomei commented Jul 2, 2021

@seehat new in https://github.com/bnomei/kirby3-htmlhead/releases/tag/v2.1.9

'htmlhead/script-js' => function ($kirby, $site, $page) {
            return ['files' => [
                // NEW !! ARRAY
                [
                    'src' => 'somescript.js', 
                    'async' => true,
                ],
                '/assets/app.js', // STRING
                'https://cdn.jsdelivr.net/npm/webfontloader@1.6.28/webfontloader.min.js|sha256-4O4pS1SH31ZqrSO2A/2QJTVjTPqVe+jnYgOWUVr7EEc=', // STRING|INTEGRIY
            ]];
        },

@bnomei bnomei closed this as completed Jul 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants