Currently I’m using the following to load my local stylesheet
app = dash.Dash(__name__ , static_folder='static')
app.layout = html.Div(className='container', children=[
html.Link(href='/static/stylesheet.css', rel='stylesheet'),
...
But I want to understand how this is different from loading local CSS and Javascript using the /assets
folder as described here
static_folder
is the main static_folder
argument given to the Flask instance, it is only kept in dash for backward compatibility. Only the assets folder have their js/css
files automatically served on the dash index.
Ok thanks for explaining!
Out of curiosity, was this simply a convenience feature (i.e automatic loading and eliminating the need to create the html.Link
) or are there other benefit out of using the assets folder pattern?
It eliminate boilerplate code to include css/files on the dash index. Before you had to add them manually to the dash resources. With Hot Reload, if there is modification in the assets folder, it will reload the page/change the loaded css.