[building] Recommendation to add inline scripts in the index.html
See original GitHub issueMy use case is add the Google Analytics script.
It’s something like:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXX');
</script>
I think the best idea could be have some option to add this script to the index.html
in the build step. Because we don’t needed during the development process, just in production/staging.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Inline JavaScript in HTML: Don't do it, unless you like really ...
While inline scripts can come in useful for backend based renderings of HTML pages, it's still not widely recommended for code reliability, ...
Read more >How does inline JavaScript work with HTML ? - GeeksforGeeks
Inline JavaScript can be achieved by using Script tag inside the body of the HTML, and instead of specifying the source(src=”…
Read more >The Script element - HTML: HyperText Markup Language
And the following examples show how to put (an inline) script inside the <script> element. <script> alert("Hello World!") ...
Read more >Where should I put <script> tags in HTML markup?
Here's what happens when a browser loads a website with a <script> tag on it: Fetch the HTML page (e.g. index.html); Begin parsing...
Read more >Basic Features: Handling Scripts - Next.js
Note: An id property must be assigned for inline scripts in order for Next.js to track and optimize the script. Executing Additional Code....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I agree that we need to do something here, I’ve had some different ideas but I haven’t had time to work it out yet.
Thanks!
Reference to docs: https://github.com/open-wc/open-wc/tree/master/packages/rollup-plugin-html#transform-output-html