Various JS optimizations

This commit is contained in:
Bernd Bestel
2023-05-21 18:01:47 +02:00
parent 825321593b
commit 979c67b44c
25 changed files with 64 additions and 87 deletions

View File

@@ -108,7 +108,8 @@
<p>
@if($mode == 'edit')
<img src="{{ $U('/battery/' . $battery->id . '/grocycode?size=60') }}"
class="float-lg-left">
class="float-lg-left"
loading="lazy">
@endif
</p>
<p>

View File

@@ -323,7 +323,8 @@
<p>
@if($mode == 'edit')
<img src="{{ $U('/chore/' . $chore->id . '/grocycode?size=60') }}"
class="float-lg-left">
class="float-lg-left"
loading="lazy">
@endif
</p>
<p>

View File

@@ -79,9 +79,12 @@
@if(GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)<strong>{{ $__t('Average shelf life') }}:</strong> <span id="productcard-product-average-shelf-life"></span><br>@endif
<strong>{{ $__t('Spoil rate') }}:</strong> <span id="productcard-product-spoil-rate"></span>
<p class="w-75 mt-3 mx-auto"><img id="productcard-product-picture"
data-src=""
class="img-fluid img-thumbnail d-none lazy"></p>
<p class="w-75 mt-3 mx-auto">
<img id="productcard-product-picture"
class="img-fluid img-thumbnail d-none"
src=""
loading="lazy">
</p>
@if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
<h5 class="mt-3">{{ $__t('Price history') }}</h5>

View File

@@ -44,9 +44,9 @@ $excludeFieldTypes = [];
<a class="show-as-dialog-link"
href="{{ $U('/files/userfiles/'. $userfieldObject->value . '?force_serve_as=picture') }}">
<img src="{{ $U('/files/userfiles/'. $userfieldObject->value . '?force_serve_as=picture&best_fit_width=32&best_fit_height=32') }}"
class="lazy"
title="{{ base64_decode(explode('_', $userfieldObject->value)[1]) }}"
alt="{{ base64_decode(explode('_', $userfieldObject->value)[1]) }}">
alt="{{ base64_decode(explode('_', $userfieldObject->value)[1]) }}"
loading="lazy">
</a>
@else
{{ $userfieldObject->value }}

View File

@@ -203,8 +203,8 @@
</div>
<img src=""
alt="{{ $userfield->name }}"
class="userfield-current-file userfield-file-show d-none lazy mt-1 discrete-link"
data-uf-name="{{ $userfield->name }}" />
class="userfield-current-file userfield-file-show d-none mt-1 discrete-link"
loading="lazy" />
</div>
@endif

View File

@@ -466,7 +466,8 @@
<i class="fa-solid fa-user"></i>
@else
<img class="rounded-circle"
src="{{ $U('/files/userpictures/' . base64_encode(GROCY_USER_PICTURE_FILE_NAME) . '_' . base64_encode(GROCY_USER_PICTURE_FILE_NAME) . '?force_serve_as=picture&best_fit_width=32&best_fit_height=32') }}">
src="{{ $U('/files/userpictures/' . base64_encode(GROCY_USER_PICTURE_FILE_NAME) . '_' . base64_encode(GROCY_USER_PICTURE_FILE_NAME) . '?force_serve_as=picture&best_fit_width=32&best_fit_height=32') }}"
loading="lazy">
@endif
{{ GROCY_USER_USERNAME }}
</a>
@@ -666,9 +667,8 @@
<a class="dropdown-item discrete-link"
href="{{ $U('/barcodescannertesting') }}"><i class="fa-solid fa-barcode"></i>&nbsp;{{ $__t('Barcode scanner testing') }}</a>
<div class="dropdown-divider"></div>
<a id="about-dialog-link"
class="dropdown-item discrete-link"
href="#"><i class="fa-solid fa-info fa-fw"></i>&nbsp;{{ $__t('About Grocy') }}</a>
<a class="dropdown-item discrete-link show-as-dialog-link"
href="{{ $U('/about?embedded') }}"><i class="fa-solid fa-info fa-fw"></i>&nbsp;{{ $__t('About Grocy') }}</a>
</div>
</li>
</ul>
@@ -696,7 +696,6 @@
<script src="{{ $U('/node_modules/toastr/build/toastr.min.js?v=', true) }}{{ $version }}"></script>
<script src="{{ $U('/node_modules/sprintf-js/dist/sprintf.min.js?v=', true) }}{{ $version }}"></script>
<script src="{{ $U('/node_modules/gettext-translator/dist/translator.js?v=', true) }}{{ $version }}"></script>
<script src="{{ $U('/node_modules/jquery-lazy/jquery.lazy.min.js?v=', true) }}{{ $version }}"></script>
<script src="{{ $U('/node_modules/nosleep.js/dist/NoSleep.min.js?v=', true) }}{{ $version }}"></script>
@if(in_array('bootstrap-combobox', $GROCY_REQUIRED_FRONTEND_PACKAGES))

View File

@@ -738,7 +738,8 @@
<p>
@if($mode == 'edit')
<img src="{{ $U('/product/' . $product->id . '/grocycode?size=60') }}"
class="float-lg-left">
class="float-lg-left"
loading="lazy">
@endif
</p>
<p>
@@ -869,8 +870,9 @@
</div>
@if($mode == "edit" && !empty($product->picture_file_name))
<img id="current-product-picture"
data-src="{{ $U('/api/files/productpictures/' . base64_encode($product->picture_file_name) . '?force_serve_as=picture&best_fit_width=400') }}"
class="img-fluid img-thumbnail mt-2 lazy mb-5">
src="{{ $U('/api/files/productpictures/' . base64_encode($product->picture_file_name) . '?force_serve_as=picture&best_fit_width=400') }}"
class="img-fluid img-thumbnail mt-2 mb-5"
loading="lazy">
<p id="delete-current-product-picture-on-save-hint"
class="form-text text-muted font-italic d-none mb-5">{{ $__t('The current picture will be deleted on save') }}</p>
@else

View File

@@ -212,8 +212,8 @@
@endif
</td>
<td>
<img data-src="{{ $U('/product/' . $product->id . '/grocycode?size=25') }}"
class="lazy">
<img src="{{ $U('/product/' . $product->id . '/grocycode?size=25') }}"
loading="lazy">
</td>
@include('components.userfields_tbody', array(

View File

@@ -326,8 +326,9 @@
</div>
@if(!empty($recipe->picture_file_name))
<img id="current-recipe-picture"
data-src="{{ $U('/api/files/recipepictures/' . base64_encode($recipe->picture_file_name) . '?force_serve_as=picture&best_fit_width=400') }}"
class="img-fluid img-thumbnail mt-2 lazy mb-5">
src="{{ $U('/api/files/recipepictures/' . base64_encode($recipe->picture_file_name) . '?force_serve_as=picture&best_fit_width=400') }}"
class="img-fluid img-thumbnail mt-2 mb-5"
loading="lazy">
<p id="delete-current-recipe-picture-on-save-hint"
class="form-text text-muted font-italic d-none mb-5">{{ $__t('The current picture will be deleted on save') }}</p>
@else
@@ -350,7 +351,8 @@
<p>
@if($mode == 'edit')
<img src="{{ $U('/recipe/' . $recipe->id . '/grocycode?size=60') }}"
class="float-lg-left">
class="float-lg-left"
loading="lazy">
@endif
</p>
<p>

View File

@@ -257,8 +257,9 @@
<div id="RecipeGalleryCard-{{ $recipe->id }}"
class="card recipe-card">
@if(!empty($recipe->picture_file_name))
<img data-src="{{ $U('/api/files/recipepictures/' . base64_encode($recipe->picture_file_name) . '?force_serve_as=picture&best_fit_width=400') }}"
class="card-img-top lazy">
<img src="{{ $U('/api/files/recipepictures/' . base64_encode($recipe->picture_file_name) . '?force_serve_as=picture&best_fit_width=400') }}"
class="card-img-top"
loading="lazy">
@endif
<div class="card-body text-center">
<h5 class="card-title mb-1">{{ $recipe->name }}</h5>
@@ -323,8 +324,9 @@
id="recipe-{{ $index + 1 }}"
role="tabpanel">
@if(!empty($recipe->picture_file_name))
<img class="card-img-top lazy"
src="{{ $U('/api/files/recipepictures/' . base64_encode($recipe->picture_file_name) . '?force_serve_as=picture') }}">
<img class="card-img-top"
src="{{ $U('/api/files/recipepictures/' . base64_encode($recipe->picture_file_name) . '?force_serve_as=picture') }}"
loading="lazy">
@endif
<div class="card-body">
<div class="shadow p-4 mb-5 bg-white rounded mt-n5 d-print-none @if(empty($recipe->picture_file_name)) d-none @endif">

View File

@@ -322,7 +322,8 @@
<div class="modal-body">
<iframe id="shopping-list-stock-add-workflow-purchase-form-frame"
class="embed-responsive"
src=""></iframe>
src=""
loading="lazy"></iframe>
</div>
<div class="modal-footer">
<span id="shopping-list-stock-add-workflow-purchase-item-count"

View File

@@ -436,8 +436,8 @@
</td>
<td>
@if(!empty($currentStockEntry->product_picture_file_name))
<img data-src="{{ $U('/api/files/productpictures/' . base64_encode($currentStockEntry->product_picture_file_name) . '?force_serve_as=picture&best_fit_width=64&best_fit_height=64') }}"
class="lazy">
<img src="{{ $U('/api/files/productpictures/' . base64_encode($currentStockEntry->product_picture_file_name) . '?force_serve_as=picture&best_fit_width=64&best_fit_height=64') }}"
loading="lazy">
@endif
</td>
<td class="@if(!GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) d-none @endif">

View File

@@ -159,8 +159,9 @@
</div>
@if(!empty($user->picture_file_name))
<img id="current-user-picture"
data-src="{{ $U('/api/files/userpictures/' . base64_encode($user->picture_file_name) . '?force_serve_as=picture&best_fit_width=400') }}"
class="img-fluid img-thumbnail mt-2 lazy mb-5">
src="{{ $U('/api/files/userpictures/' . base64_encode($user->picture_file_name) . '?force_serve_as=picture&best_fit_width=400') }}"
class="img-fluid img-thumbnail mt-2 mb-5"
loading="lazy">
<p id="delete-current-user-picture-on-save-hint"
class="form-text text-muted font-italic d-none mb-5">{{ $__t('The current picture will be deleted on save') }}</p>
@else