Fix and optimize shop styles and remove jquery
Reduce bootstrap bundle, replace jquery dependant code and remove jquery. Optimize style loading. Overall the lighthouse metrics are far better now. Signed-off-by: Egor Savkin <es@m-labs.hk>
This commit is contained in:
parent
10435277cd
commit
b359af1e5a
859
package-lock.json
generated
859
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,8 @@
|
|||||||
"start": "npx webpack --watch",
|
"start": "npx webpack --watch",
|
||||||
"build": "npx webpack",
|
"build": "npx webpack",
|
||||||
"start-dev": "npx webpack --watch --mode=development --devtool=inline-source-map",
|
"start-dev": "npx webpack --watch --mode=development --devtool=inline-source-map",
|
||||||
"build-dev": "npx webpack --mode=development --devtool=inline-source-map"
|
"build-dev": "npx webpack --mode=development --devtool=inline-source-map",
|
||||||
|
"optimize-bootstrap": "zola build -o tmp_out && npx purgecss --css static/css/bootstrap-5.3.0.min.css --content 'tmp_out/**/*.html' -o static/css/bootstrap-5.3.0.opt.css --safelist modal-backdrop && rm -rf tmp_out"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -33,7 +34,8 @@
|
|||||||
"babel-preset-minify": "^0.5.2",
|
"babel-preset-minify": "^0.5.2",
|
||||||
"webpack": "^5.93.0",
|
"webpack": "^5.93.0",
|
||||||
"webpack-cli": "^5.1.4",
|
"webpack-cli": "^5.1.4",
|
||||||
"webpack-preprocessor-loader": "^1.3.0"
|
"webpack-preprocessor-loader": "^1.3.0",
|
||||||
|
"purgecss": "^7.0.2"
|
||||||
},
|
},
|
||||||
"babel": {
|
"babel": {
|
||||||
"presets": [
|
"presets": [
|
||||||
|
5
static/css/bootstrap-5.3.0.opt.css
vendored
Normal file
5
static/css/bootstrap-5.3.0.opt.css
vendored
Normal file
File diff suppressed because one or more lines are too long
2
static/js/jquery-3.7.0.min.js
vendored
2
static/js/jquery-3.7.0.min.js
vendored
File diff suppressed because one or more lines are too long
2
static/js/jquery-3.7.0.slim.min.js
vendored
2
static/js/jquery-3.7.0.slim.min.js
vendored
File diff suppressed because one or more lines are too long
@ -2,8 +2,6 @@ var CACHE_NAME = 'ml-03';
|
|||||||
var urlsToCache = [
|
var urlsToCache = [
|
||||||
'/css/bootstrap-5.3.0.min.css',
|
'/css/bootstrap-5.3.0.min.css',
|
||||||
'/css/styles.css',
|
'/css/styles.css',
|
||||||
'/js/jquery-3.7.0.slim.min.js',
|
|
||||||
'/js/jquery-3.7.0.min.js',
|
|
||||||
'/js/bootstrap-5.3.0.min.js',
|
'/js/bootstrap-5.3.0.min.js',
|
||||||
'/js/react.production.min.js',
|
'/js/react.production.min.js',
|
||||||
'/js/react-dom.production.min.js',
|
'/js/react-dom.production.min.js',
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
<link href="{{ get_url(path='favicon.ico', cachebust=true) }}" rel="shortcut icon" type="image/x-icon">
|
<link href="{{ get_url(path='favicon.ico', cachebust=true) }}" rel="shortcut icon" type="image/x-icon">
|
||||||
<link href="{{ get_url(path='favicon.ico', cachebust=true) }}" rel="icon" type="image/x-icon">
|
<link href="{{ get_url(path='favicon.ico', cachebust=true) }}" rel="icon" type="image/x-icon">
|
||||||
|
|
||||||
<link rel="stylesheet" href="{{ get_url(path='css/bootstrap-5.3.0.min.css', cachebust=true) }}">
|
<link rel="stylesheet" href="{{ get_url(path='css/bootstrap-5.3.0.opt.css', cachebust=true) }}">
|
||||||
<link rel="stylesheet" href="{{ get_url(path='css/styles.css', cachebust=true) }}">
|
<link rel="stylesheet" href="{{ get_url(path='css/styles.css', cachebust=true) }}">
|
||||||
{% block styles %}{% endblock %}
|
{% block styles %}{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
@ -155,7 +155,6 @@
|
|||||||
|
|
||||||
<!-- ./FOOTER -->
|
<!-- ./FOOTER -->
|
||||||
|
|
||||||
<script src="{{ get_url(path='js/jquery-3.7.0.slim.min.js', cachebust=true) }}"></script>
|
|
||||||
<script src="{{ get_url(path='js/bootstrap-5.3.0.bundle.min.js', cachebust=true) }}"></script>
|
<script src="{{ get_url(path='js/bootstrap-5.3.0.bundle.min.js', cachebust=true) }}"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -42,12 +42,12 @@
|
|||||||
<link href="{{ get_url(path='favicon.ico', cachebust=true) }}" rel="shortcut icon" type="image/x-icon">
|
<link href="{{ get_url(path='favicon.ico', cachebust=true) }}" rel="shortcut icon" type="image/x-icon">
|
||||||
<link href="{{ get_url(path='favicon.ico', cachebust=true) }}" rel="icon" type="image/x-icon">
|
<link href="{{ get_url(path='favicon.ico', cachebust=true) }}" rel="icon" type="image/x-icon">
|
||||||
|
|
||||||
<link rel="stylesheet" href="{{ get_url(path='css/bootstrap-5.3.0.min.css', cachebust=true) }}" as="style">
|
|
||||||
<link rel="stylesheet" href="{{ get_url(path='css/styles.css', cachebust=true) }}" as="style">
|
|
||||||
|
|
||||||
|
|
||||||
{% block links %}{% endblock %}
|
{% block links %}{% endblock %}
|
||||||
{% block styles %}{% endblock %}
|
|
||||||
|
{% block styles %}
|
||||||
|
<link rel="stylesheet" href="{{ get_url(path='css/bootstrap-5.3.0.opt.css', cachebust=true) }}">
|
||||||
|
<link rel="stylesheet" href="{{ get_url(path='css/styles.css', cachebust=true) }}">
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
@ -171,7 +171,6 @@
|
|||||||
|
|
||||||
<!-- <script src="{{ get_url(path='js/as.js', cachebust=true) }}"></script> -->
|
<!-- <script src="{{ get_url(path='js/as.js', cachebust=true) }}"></script> -->
|
||||||
|
|
||||||
<script src="{{ get_url(path='js/jquery-3.7.0.min.js', cachebust=true) }}"></script>
|
|
||||||
<script src="{{ get_url(path='js/bootstrap-5.3.0.bundle.min.js', cachebust=true) }}" defer></script>
|
<script src="{{ get_url(path='js/bootstrap-5.3.0.bundle.min.js', cachebust=true) }}" defer></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -186,16 +185,20 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(function () {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
$('#modalEnlarged').on('hidden.bs.modal', function (e) {
|
const modal = document.getElementById('modalEnlarged');
|
||||||
$('#enlarged').attr('src', '');
|
const enlargedImg = document.getElementById('enlarged');
|
||||||
});
|
|
||||||
|
|
||||||
$('[data-popup]').click(function (evt) {
|
modal.addEventListener('hidden.bs.modal', function() {
|
||||||
var _self = $(this);
|
enlargedImg.src = '';
|
||||||
var _img_enlarged = _self.data('nsrc');
|
});
|
||||||
$('#enlarged').attr('src', _img_enlarged);
|
document.querySelectorAll('[data-popup]').forEach(function(element) {
|
||||||
$('#modalEnlarged').modal('show');
|
element.addEventListener('click', function() {
|
||||||
|
const imgSrc = this.dataset.nsrc;
|
||||||
|
enlargedImg.src = imgSrc;
|
||||||
|
const bsModal = new bootstrap.Modal(modal);
|
||||||
|
bsModal.show();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
|
|
||||||
{% block styles %}
|
{% block styles %}
|
||||||
{{ super() }}
|
<link rel="stylesheet" href="{{ get_url(path='css/bootstrap-5.3.0.min.css', cachebust=true) }}">
|
||||||
|
<link rel="stylesheet" href="{{ get_url(path='css/styles.css', cachebust=true) }}">
|
||||||
<link rel="stylesheet" href="{{ get_url(path='css/order-hardware.css', cachebust=true) }}">
|
<link rel="stylesheet" href="{{ get_url(path='css/order-hardware.css', cachebust=true) }}">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{% extends 'section.html' %}
|
{% extends 'section.html' %}
|
||||||
|
|
||||||
{% block styles %}
|
{% block styles %}
|
||||||
|
{{ super() }}
|
||||||
<style>
|
<style>
|
||||||
h5 {
|
h5 {
|
||||||
margin-bottom: 2rem!important;
|
margin-bottom: 2rem!important;
|
||||||
|
Loading…
Reference in New Issue
Block a user