app.scripts.append_script is the right approach here. Iâve used this with google analytics before and it works. See https://plot.ly/dash/external-resources for more.
app.scripts.append_script seems that works fine for scripts that runs just at the beginning, but I canât get running just the adsense one.
Will html.Script work sometime? I think with that component I will be able to place it on the app layout easily and will be visible.
For whoever is having issues, could you paste a screenshot of the network tab of your browser displaying the request?
My guess is that the server that is serving the adsense.js code isnât setting the correct content-type (it should be text/javascript) and so the script isnât getting executed. This is why @Sherm4nLCâs solution of using rawgit.com to serve the file (f it is hosted on gist or github) worked.
server = Flask(__name__)
app = dash.Dash(
__name__,
server = server
,external_stylesheets=["https://cdnjs.cloudflare.com/ajax/libs/vis/4.20.1/vis.min.css"]
)