Skip to content

Commit

Permalink
move lazysizes JS entrypoint over to vite
Browse files Browse the repository at this point in the history
  • Loading branch information
jrochkind committed Oct 13, 2022
1 parent a3c0c6c commit d3ac9d5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions app/frontend/entrypoints/lazysizes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// A SEPARATE JS entrypoint file with JUST lazysizes. While may load our other JS
// as 'deferred' or at bottom of page, lazysizes recommends loading early.
//
// https://github.com/aFarkas/lazysizes#include-early

import 'lazysizes';
lazySizes.init();
4 changes: 2 additions & 2 deletions app/views/layouts/admin.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

<%= render "layouts/head_tag_common" %>

<%# lazysizes gets it's own "pack", loaded early without 'defer', per lazysizes doc suggestion %>
<%= javascript_pack_tag 'lazysizes' %>
<%# lazysizes gets it's own entrypoint, loaded early without 'defer', per lazysizes doc suggestion %>
<%= vite_javascript_tag 'lazysizes' %>

<%# sprockets 'application' js and css %>
<%= stylesheet_link_tag 'application', media: 'all' %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<%= render "layouts/head_tag_common" %>

<%# goes first and separate per lazysizes docs %>
<%= javascript_pack_tag 'lazysizes' %>
<%= vite_javascript_tag 'lazysizes' %>

<%= stylesheet_link_tag "application", media: "all" %>

Expand Down

0 comments on commit d3ac9d5

Please sign in to comment.