mirror of
https://github.com/sb745/NyaaV3.git
synced 2025-03-12 22:06:55 +02:00
Use Flask-Assets to minify self-hosted JS files (#468)
* Use Flask-Assets to minify self-hosted JS files By having Flask-Assets minify the two JS files we ship, namely main.js and bootstrap-select.js, we can shave off 28406 bytes. The minified files are generated on startup. If one wishes to manually clean them up or build them, they can use the "flask assets" management command, e.g. "flask assets clean". * Workaround to fix tests State carries over in tests, which is the dumbest shit ever. Fix it by clearing the bundles before setting them.
This commit is contained in:
parent
03094b6d36
commit
291f859a4f
2 changed files with 12 additions and 2 deletions
|
@ -81,6 +81,12 @@ def create_app(config):
|
||||||
|
|
||||||
# Assets
|
# Assets
|
||||||
assets.init_app(app)
|
assets.init_app(app)
|
||||||
|
assets._named_bundles = {} # Hack to fix state carrying over in tests
|
||||||
|
main_js = Bundle('js/main.js', filters='rjsmin', output='js/main.min.js')
|
||||||
|
bs_js = Bundle('js/bootstrap-select.js', filters='rjsmin',
|
||||||
|
output='js/bootstrap-select.min.js')
|
||||||
|
assets.register('main_js', main_js)
|
||||||
|
assets.register('bs_js', bs_js)
|
||||||
# css = Bundle('style.scss', filters='libsass',
|
# css = Bundle('style.scss', filters='libsass',
|
||||||
# output='style.css', depends='**/*.scss')
|
# output='style.css', depends='**/*.scss')
|
||||||
# assets.register('style_all', css)
|
# assets.register('style_all', css)
|
||||||
|
|
|
@ -45,8 +45,12 @@
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/8.3.1/markdown-it.min.js" integrity="sha256-3WZyZQOe+ql3pLo90lrkRtALrlniGdnf//gRpW0UQks=" crossorigin="anonymous"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/8.3.1/markdown-it.min.js" integrity="sha256-3WZyZQOe+ql3pLo90lrkRtALrlniGdnf//gRpW0UQks=" crossorigin="anonymous"></script>
|
||||||
<!-- Modified to not apply border-radius to selectpickers and stuff so our navbar looks cool -->
|
<!-- Modified to not apply border-radius to selectpickers and stuff so our navbar looks cool -->
|
||||||
<script src="{{ static_cachebuster('js/bootstrap-select.js') }}"></script>
|
{% assets "bs_js" %}
|
||||||
<script src="{{ static_cachebuster('js/main.js') }}"></script>
|
<script src="{{ static_cachebuster('js/bootstrap-select.min.js') }}"></script>
|
||||||
|
{% endassets %}
|
||||||
|
{% assets "main_js" %}
|
||||||
|
<script src="{{ static_cachebuster('js/main.min.js') }}"></script>
|
||||||
|
{% endassets %}
|
||||||
|
|
||||||
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
|
|
Loading…
Add table
Reference in a new issue