feat(experimental): minify js files using esbuild
Some checks are pending
Build and release container directly from master / release (push) Waiting to run
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (1.12.1, true) (push) Waiting to run
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (1.13.2, true) (push) Waiting to run
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (1.14.0, true) (push) Waiting to run
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (1.15.0, true) (push) Waiting to run
Invidious CI / build - crystal: ${{ matrix.crystal }}, stable: ${{ matrix.stable }} (nightly, false) (push) Waiting to run
Invidious CI / build-docker (push) Waiting to run
Invidious CI / build-docker-arm64 (push) Waiting to run
Invidious CI / lint (push) Waiting to run

This commit is contained in:
Fijxu
2025-04-05 00:39:05 -03:00
parent e3d60a0517
commit bbec111997
19 changed files with 131 additions and 25 deletions

View File

@@ -160,6 +160,15 @@ LOGGER = Invidious::LogHandler.new(OUTPUT, CONFIG.log_level, CONFIG.colorize_log
# Check table integrity
Invidious::Database.check_integrity(CONFIG)
# Minifies Invidious Javascript
{% if flag?(:minify_debug) || (flag?(:release) || flag?(:production)) && !flag?(:skip_minified_js) %}
{% puts "\nMinifying Invidious JavaScript\n" %}
{% puts run("../scripts/minify-js.cr").stringify %}
JS_PATH="js/minified"
{% else %}
JS_PATH="js"
{% end %}
{% if !flag?(:skip_videojs_download) %}
# Resolve player dependencies. This is done at compile time.
#

View File

@@ -29,7 +29,7 @@
}.to_pretty_json
%>
</script>
<script src="/js/playlist_widget.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/<%= JS_PATH %>/playlist_widget.js?v=<%= ASSET_COMMIT %>"></script>
<%= rendered "components/items_paginated" %>

View File

@@ -45,7 +45,7 @@
<link rel="alternate" type="application/rss+xml" title="RSS" href="/feed/channel/<%= ucid %>" />
<%- end -%>
<script src="/js/pagination.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/<%= JS_PATH %>/pagination.js?v=<%= ASSET_COMMIT %>"></script>
<link rel="alternate" href="<%= youtube_url %>">
<title><%= author %> - Invidious</title>

View File

@@ -43,4 +43,4 @@
}.to_pretty_json
%>
</script>
<script src="/js/community.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/<%= JS_PATH %>/community.js?v=<%= ASSET_COMMIT %>"></script>

View File

@@ -18,4 +18,4 @@
%>
</script>
<script src="/js/watched_indicator.js"></script>
<script src="/<%= JS_PATH %>/watched_indicator.js"></script>

View File

@@ -86,4 +86,4 @@
}.to_pretty_json
%>
</script>
<script src="/js/player.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/<%= JS_PATH %>/player.js?v=<%= ASSET_COMMIT %>"></script>

View File

@@ -27,7 +27,7 @@
}.to_pretty_json
%>
</script>
<script src="/js/subscribe_widget.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/<%= JS_PATH %>/subscribe_widget.js?v=<%= ASSET_COMMIT %>"></script>
<% else %>
<a id="subscribe" class="pure-button pure-button-primary"
href="/login?referer=<%= env.get("current_page") %>">

View File

@@ -11,7 +11,7 @@
<link rel="stylesheet" href="/css/default.css?v=<%= ASSET_COMMIT %>">
<link rel="stylesheet" href="/css/embed.css?v=<%= ASSET_COMMIT %>">
<title><%= HTML.escape(video.title) %> - Invidious</title>
<script src="/js/_helpers.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/<%= JS_PATH %>/_helpers.js?v=<%= ASSET_COMMIT %>"></script>
</head>
<body class="dark-theme">
@@ -32,6 +32,6 @@
</script>
<%= rendered "components/player" %>
<script src="/js/embed.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/<%= JS_PATH %>/embed.js?v=<%= ASSET_COMMIT %>"></script>
</body>
</html>

View File

@@ -25,7 +25,7 @@
}.to_pretty_json
%>
</script>
<script src="/js/watched_widget.js"></script>
<script src="/<%= JS_PATH %>/watched_widget.js"></script>
<div class="pure-g">
<% watched.each do |item| %>

View File

@@ -40,4 +40,4 @@
<% end %>
</div>
<script src="/js/watched_indicator.js"></script>
<script src="/<%= JS_PATH %>/watched_indicator.js"></script>

View File

@@ -17,4 +17,4 @@
<% end %>
</div>
<script src="/js/watched_indicator.js"></script>
<script src="/<%= JS_PATH %>/watched_indicator.js"></script>

View File

@@ -53,7 +53,7 @@
}.to_pretty_json
%>
</script>
<script src="/js/watched_widget.js"></script>
<script src="/<%= JS_PATH %>/watched_widget.js"></script>
<div class="pure-g">
@@ -62,7 +62,7 @@
<% end %>
</div>
<script src="/js/watched_indicator.js"></script>
<script src="/<%= JS_PATH %>/watched_indicator.js"></script>
<%=
IV::Frontend::Pagination.nav_numeric(locale,

View File

@@ -46,4 +46,4 @@
<% end %>
</div>
<script src="/js/watched_indicator.js"></script>
<script src="/<%= JS_PATH %>/watched_indicator.js"></script>

View File

@@ -118,7 +118,7 @@
}.to_pretty_json
%>
</script>
<script src="/js/playlist_widget.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/<%= JS_PATH %>/playlist_widget.js?v=<%= ASSET_COMMIT %>"></script>
<% end %>

View File

@@ -44,5 +44,5 @@
}.to_pretty_json
%>
</script>
<script src="/js/comments.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/post.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/<%= JS_PATH %>/comments.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/<%= JS_PATH %>/post.js?v=<%= ASSET_COMMIT %>"></script>

View File

@@ -22,7 +22,7 @@
<link rel="stylesheet" href="/css/ionicons.min.css?v=<%= ASSET_COMMIT %>">
<link rel="stylesheet" href="/css/default.css?v=<%= ASSET_COMMIT %>">
<link rel="stylesheet" href="/css/carousel.css?v=<%= ASSET_COMMIT %>">
<script src="/js/_helpers.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/<%= JS_PATH %>/_helpers.js?v=<%= ASSET_COMMIT %>"></script>
</head>
<body class="<%= dark_mode.blank? ? "no" : dark_mode %>-theme">
@@ -163,10 +163,10 @@
</div>
</div>
<script src="/js/handlers.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/themes.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/<%= JS_PATH %>/handlers.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/<%= JS_PATH %>/themes.js?v=<%= ASSET_COMMIT %>"></script>
<% if env.get? "user" %>
<script src="/js/sse.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/<%= JS_PATH %>/sse.js?v=<%= ASSET_COMMIT %>"></script>
<script id="notification_data" type="application/json">
<%=
{
@@ -176,7 +176,7 @@
%>
</script>
<% if CONFIG.enable_user_notifications %>
<script src="/js/notifications.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/<%= JS_PATH %>/notifications.js?v=<%= ASSET_COMMIT %>"></script>
<% end %>
<% end %>

View File

@@ -199,7 +199,7 @@ we're going to need to do it here in order to allow for translations.
}.to_pretty_json
%>
</script>
<script src="/js/playlist_widget.js?v=<%= Time.utc.to_unix_ms %>"></script>
<script src="/<%= JS_PATH %>/playlist_widget.js?v=<%= Time.utc.to_unix_ms %>"></script>
<% end %>
<% end %>
@@ -391,5 +391,5 @@ we're going to need to do it here in order to allow for translations.
</div>
<% end %>
</div>
<script src="/js/comments.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/js/watch.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/<%= JS_PATH %>/comments.js?v=<%= ASSET_COMMIT %>"></script>
<script src="/<%= JS_PATH %>/watch.js?v=<%= ASSET_COMMIT %>"></script>