question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[building] Recommendation to add inline scripts in the index.html

See original GitHub issue

My 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:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
LarsDenBakkercommented, Dec 8, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found