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.

Combine repeated script/style tags

See original GitHub issue

Repeated tags like:

<script>console.log("hi");</script>
<script>console.log("hi");</script>

could be combined into:

<script>console.log("hi");console.log("hi");</script>

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
KenSharpcommented, Mar 5, 2016

I know it’s not supported by the browsers (yet) but there’s also <style scoped> to think about. The minifier would either need to know which parent element the scoped refers to, or just ignore it. Combining the scopeds together sounds like a nightmare.

0reactions
DamonHDcommented, Sep 7, 2017

A possibly related suggestion…

When the same async script is included in the document multiple times, such as for simple inclusion of Google AdSense code, it is in that case, and possibly in general OK, to omit the second and subsequent attempts to load the script, eg in:

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-XXX"
data-ad-slot="YYYY"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
....
....
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-XXX"
data-ad-slot="YYYY"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
....

it saves page weight and possibly some redundant Shift-RELOAD activity in my observation to omit the second:

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

Rgds

Damon

Read more comments on GitHub >

github_iconTop Results From Across the Web

combine duplicate rows in apps script - Stack Overflow
I want apps script to combine duplicate rows and this script will run on the onEdit trigger. – Onkar Pawar. Aug 18, 2021...
Read more >
How to Combine Duplicate Rows and Sum the Values in Excel
The above steps would consolidate the data by removing the duplicate entries and adding the values for each country. Dataset where duplicate rows...
Read more >
Writing multiple Vue components in a single file
Writing multiple components in one file is a pattern from React where some files contain multiple components. Some of those components are ...
Read more >
Is it possible to combine multiple <style> tags into one? #2217
Just noticing that I have about a hundred or so <style data-emotion="css" data-s> tags in the DOM and am looking for an option...
Read more >
Configuring PageSpeed Filters
Combines multiple <head> elements found in document into one. inline_import_to_link, Yes, No, Inlines <style> tags comprising only CSS @imports by converting ...
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