cloudflare / templates

A collection of starter templates and examples for Cloudflare Workers and Pages
https://cloudflareworkers.com
MIT License
999 stars 632 forks source link

Support for third party scripts #26

Closed dschmidtadv closed 1 year ago

dschmidtadv commented 5 years ago

A lot of scripts nowadays are added to the HTML using code such as

insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga')

It would be great if caching those locally would be supported.

reinder42 commented 5 years ago

If I'm not mistaken, JavaScript like that is executed in the browser, so it'll use browser-level caching of the original script (GA, etc.) when possible

350d commented 5 years ago

@dschmidtadv You need to update .js url and point it to your CF proxy folder like /proxy/www.google-analytics.com/analytics.js for example.

lauragift21 commented 1 year ago

Closing this issue because the initial question was addressed. Also the templates have moved over to the worker-sdk monorepo: https://github.com/cloudflare/workers-sdk/tree/main/templates.

if you're still experiencing issues feel free to open an issue there.