Skip to content

Commit

Permalink
add compression of js/css assets
Browse files Browse the repository at this point in the history
  • Loading branch information
akbarkz committed Jan 23, 2025
1 parent 0fe2c82 commit 533c299
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ bleach==6.0.0
numpy==1.24.4
python-slugify==8.0.1
djlint==1.34.1
flask-squeeze==3.1.0
2 changes: 1 addition & 1 deletion templates/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<script src="{{ versioned_static('js/src/navigation.js') }}" defer></script>
<script src="{{ versioned_static('js/dist/main.js') }}" defer></script>
<script src="{{ versioned_static('js/src/infer-preferred-language.js')}}"></script>
<script src="{{ versioned_static('js/src/infer-preferred-language.js')}}" defer></script>

<link rel="stylesheet" type="text/css" media="screen" href="{{ versioned_static("css/styles.css") }}" />
<link rel="stylesheet" type="text/css" media="print" href="{{ versioned_static("css/print.css") }}" />
Expand Down
5 changes: 5 additions & 0 deletions webapp/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import talisker.requests
from jinja2 import ChoiceLoader, FileSystemLoader
from pathlib import Path
from flask_squeeze import Squeeze

from canonicalwebteam.blog import BlogAPI, BlogViews, build_blueprint
from canonicalwebteam.discourse import (
Expand Down Expand Up @@ -184,6 +185,10 @@
static_folder="../static",
)

# Compress JS and CSS
squeeze = Squeeze()
squeeze.init_app(app)

# ChoiceLoader attempts loading templates from each path in successive order
loader = ChoiceLoader(
[
Expand Down

0 comments on commit 533c299

Please sign in to comment.