Skip to content

Commit

Permalink
defer some more
Browse files Browse the repository at this point in the history
  • Loading branch information
hexylena committed Mar 5, 2024
1 parent 3c739af commit f3f095d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ javascript_bundles:
- assets/js/theme.js
main:
preload: true
defer: true
async: true
resources:
- assets/js/jquery.slim.min.js # Mandatory for bootstrap.
- assets/js/popper.min.js # Everywhere, dropdown menu.
Expand Down
2 changes: 1 addition & 1 deletion _layouts/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ <h2>Meet & Join the Community!</h2>
<h2>GTN Toots</h2>

<link rel="stylesheet" type="text/css" href="{{ site.baseurl }}/assets/js/emfed/toots.css">
<script type="module" src="{{ site.baseurl }}/assets/js/emfed/emfed.js"></script>
<script async defer type="module" src="{{ site.baseurl }}/assets/js/emfed/emfed.js"></script>
<a rel="me" class="mastodon-feed"
href="https://mstdn.science/@gtn"
data-toot-limit="3"
Expand Down
11 changes: 9 additions & 2 deletions _plugins/jekyll-bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,12 @@ def load_bundle_dev(name)

baseurl = @context.registers[:site].config['baseurl']

attrs = ""
attrs += " async" if bundle['async']
attrs += " defer" if bundle['defer']

bundle['resources'].map do |f|
"<script src='#{baseurl}/#{f}'></script>"
"<script #{attrs} src='#{baseurl}/#{f}'></script>"
end.join("\n")
end

Expand All @@ -99,8 +103,11 @@ def load_bundle_production(name)
raise "Bundle #{name} not found in site config" if bundle.nil?

baseurl = @context.registers[:site].config['baseurl']
attrs = ""
attrs += " async" if bundle['async']
attrs += " defer" if bundle['defer']
bundle_path = "#{baseurl}#{bundle['path']}?v=#{bundle['timestamp']}"
"<script src='#{bundle_path}'></script>"
"<script #{attrs} src='#{bundle_path}'></script>"
end
end
end
Expand Down

0 comments on commit f3f095d

Please sign in to comment.