Skip to main content

remove unused javascript final

Yeh codes website mein specific changes laane ke liye hai. Chaliye, in codes ke kaam aur purpose ko simple taur par samjhayen:

1. @font-face CSS Code:

  • Purpose: Custom font ko load karne ke liye hota hai.
  • Kaam: Web font ko define karke use karna chahte hain. Is code mein, apni pasand ki font ko define kiya jata hai (your-font.woff ya your-font.woff2), jo website par text elements mein apply ki ja sakti hai.

2. Google Analytics Code Replacement:

  • Purpose: Google Analytics ka async script load karne ke liye hota hai.
  • Kaam: Website par Google Analytics script ko asynchronous tarike se load karna hai, jisse page ke performance par asar kam ho. Existing Google Tag Manager script ko replace karke, page load hone ke baad GA script ko load karta hai.

3. Google Translate Button Code Replacement:

  • Purpose: Google Translate button ko trigger karne ke liye hota hai.
  • Kaam: Translate button ko load karne ke liye hai, jisse users content ko apni preferred language mein translate kar sakein. Existing translate script ko button click hone par load karta hai.

In codes ka use specific functionalities ko enhance karne ke liye kiya gaya hai, jaise fonts ko custom load karna, Google Analytics ka load optimize karna, aur website par translation feature ko enable karna. Each code snippet ka use specific aspect ko modify ya improve karne ke liye hota hai.


 #1


go to

theme- customize-advance-ADD CSS-PASTE CODE

@font-face {

  font-family: 'YourFontFamily';

  src: url('your-font.woff2') format('woff2'),

       url('your-font.woff') format('woff');

  font-weight: normal;

  font-style: normal;

  font-display: swap; /* Add this line */

}


#2 theme html



<script async='async' src='https://www.googletagmanager.com/gtag/js?id=G-4XZH1Z7SLF'/>

replace ☝upper code which is giveing problem for loading performance with this code

<!-- JavaScript for lazy loading -->

<script>

  var isGALoaded = false;


  // Function to load Google Analytics

  function loadGoogleAnalytics() {

    if (!isGALoaded) {

      var script = document.createElement('script');

      script.src = 'URL_TO_YOUR_GOOGLE_ANALYTICS_SCRIPT';

      document.body.appendChild(script);

      isGALoaded = true;

    }

  }


  // Trigger Google Analytics load when page loads

  window.addEventListener('load', function() {

    loadGoogleAnalytics(); // This will load GA script after the page loads

  });

</script>


#3 html theme 


 <script src='//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit'/>

replace this code  ☝ to this code👇

<!-- Add this button wherever you want to trigger the translation -->
<button id="loadTranslate">Load Translation</button>

<!-- Add this script in your template -->
<script>
document.getElementById('loadTranslate').addEventListener('click', function() {
  var script = document.createElement('script');
  script.src = 'https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit';
  document.head.appendChild(script);
});
</script>


Still haveing more problem related to this

Reduce unused JavaScript
0.36s
Reduce unused JavaScript and defer loading scripts until they are required to decrease bytes consumed by network activity. Learn how to reduce unused JavaScript.LCP
URL


Blogger
 Hosting 1st Party




…res/139…-rockpool_compiled.js
(resources.blogblog.com)












solving here widgets.js problem

LCP widgets.js TEXT ISSUE BLOGGER
https://www.youtube.com/watch?v=e42j1sg1ZXI


solution
replace </body> the body tag in the html of the theme which is at the end of the html code placed with this tag 


&lt;!--</body>--&gt;&lt;/body&gt;
 save problem solved


#2

Reduce unused JavaScript
0.30s
Reduce unused JavaScript and defer loading scripts until they are required to decrease bytes consumed by network activity. Learn how to reduce unused JavaScript.LCP
URL
Transfer Size
Potential Savings
Blogger
 Hosting 1st Party
46.9 KiB
27.2 KiB
…res/139…-rockpool_compiled.js
(resources.blogblog.com)
46.9 KiB
27.2 KiB

Reduce unused JavaScript 0.30s Reduce unused JavaScript and defer loading scripts until they are required to decrease bytes consumed by network activity. Learn how to reduce unused JavaScript.LCP URL Transfer Size Potential Savings Blogger Hosting 1st Party 46.9 KiB 27.2 KiB …res/139…-rockpool_compiled.js(resources.blogblog.com) 46.9 KiB 27.2 KiB


 

Remove unused Javascript 


Reduce unused JavaScript
0.75s
Reduce unused JavaScript and defer loading scripts until they are required to decrease bytes consumed by network activity. Learn how to reduce unused JavaScript.LCP
URL
Transfer Size
Potential Savings
Facebook
 Social 
87.7 KiB
63.4 KiB
/en_US/sdk.js?hash=992c84f…
(connect.facebook.net)
87.7 KiB
63.4 KiB

https://www.youtube.com/watch?v=nBnf41n_Gi8

search script /en_US


 js.src = &#39;https://connect.facebook.net/en_US/sdk.js#xfbml=1&amp;version=v13.0&#39;;

you will 👆upper line code remove it from the theme html 


search script  sdk.js


js.src = 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.0';

you will 👆upper line code remove it from the theme html 




Comments

Popular posts from this blog

ai tool

 https://smodin.io/free-english-rewriter-and-spinner/ai-detection-remover ai detecter and removal https://originality.ai/blog/highlight-ai-text= for ai highlighter and affiliate marketing https://gptzero.me/  = ai writing detector and highlighter  https://www.zerogpt.com/           = ai content writer detector https://plagiarism-remover.com/humanize-ai-text/           = humanize writer

Add Code Box

  HTML CSS And Java Script  <style> .K2_CBox{position:relative;background:#fff;width:100%;border-radius:6px;box-shadow: rgba(0, 0, 0, 0.15) 1.95px 1.95px 2.6px;padding:10px;margin:30px 0 30px} .K2_CBox .CB_Heading{display:flex;justify-content:space-between;align-items:center;margin-bottom:15px} .K2_CBox .CB_Heading span{margin:0;font-weight:700;font-family:inherit;font-size:1.1rem} .K2_CBox .C_box_main{cursor:pointer;display:inline-flex;align-items:center;padding:12px;outline:0;border:0;border-radius:50%;background:#004cbd;transition:all .3s ease;-webkit-transition:all .3s ease}.K2_CBox .C_box_main:hover{opacity:.8}.K2_CBox .C_box_main .CBox_icn{flex-shrink:0;display:inline-block;width:18px;height:18px;background-image:url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%23fefefe' stroke-linecap='round' stroke-linejoin='round' stroke-wi...

create a list of 100 things someone may now know about SEO

  create a list of 100 things someone may now know abouT SEO stands for Search Engine Optimization. SEO is the process of optimizing a website to improve its visibility and ranking on search engines. Google is the most popular search engine, followed by Bing and Yahoo. SEO involves both on-page and off-page optimization techniques. On-page optimization includes optimizing the content and structure of a website. Off-page optimization includes building backlinks to a website. SEO requires constant monitoring and updating to maintain rankings. Keyword research is the foundation of SEO. Long-tail keywords are easier to rank for than short-tail keywords. Keyword stuffing is a black hat SEO technique that can get a website penalized. Meta tags are important for on-page optimization. Title tags and meta descriptions should be unique and relevant to the page. Header tags (H1, H2, H3) are important for on-page optimization. Content should be well-written and provide value to the reader. Dup...