Hi,
I would like to know if there is a possibility to speed up the loading process of my dash app by defer the javascripts used in the app.
I tried to check the loading speed of my dash app using Google Page Speed Insights and GTmetrix, but the result is only around 70-80% for desktop and lower for mobile. Or maybe some code in my app makes the page slower when it is loading? This is just a simple dash app and not yet contains any code related to plotting/graph of data.
my app.py code:
# -*- coding: utf-8 -*-
import dash
import dash_bootstrap_components as dbc
import dash_core_components as dcc
import dash_html_components as html
import page_layout as pl
# using dash-bootstrap-components for our external stylesheets
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
# setup container for our page-content that will be called based on the url/pathname
dynamic_body_content = html.Div([
dcc.Location(id='url', refresh=False),
html.Div(id='page-content')
])
# initiate the app layout which consists of navbar and dinamically loaded body content
app.layout = html.Div([pl.navbar, dynamic_body_content])
# setup the callback for each page
@app.callback(dash.dependencies.Output('page-content', 'children'),
[dash.dependencies.Input('url', 'pathname')])
def display_page(pathname):
if pathname == '/kebijakan-privasi':
return pl.body_kebijakan_privasi, pl.body_footer
elif pathname == '/tos':
return pl.body_tos, pl.body_footer
elif pathname == '/disclaimer':
return pl.body_disclaimer, pl.body_footer
elif pathname == '/dashboard':
return pl.body_grafana, pl.body_footer
elif pathname == '/about':
return pl.body_about, pl.body_footer
elif pathname == '/':
return pl.body_index, pl.body_footer
else:
return pl.body_index, pl.body_footer
server = app.server
# Start the app server
if __name__ == '__main__':
app.run_server(debug=False)