December 1, 2022

Blog @ Munaf Sheikh

Latest news from tech-feeds around the world.

10 Rules To Integrate Third-Party Scripts

Great post from our friends at Source link


Third-party scripts can cause negative load-time effects. Why is this an issue? Well, in Google’s view, a poorly-optimized page should not rank highly. Instead, search results should favor pages with fundamental design strengths — including JavaScript minification, rapid execution time, and render-friendly scripting. 

In reflection of this belief, Google has planned the gradual release of a major update to its search algorithm that is scheduled for June through August of 2021. This update will increase the importance of a page’s loading speed as a contributing factor to a web page’s overall ranking on Google’s search results page. As a result, how third-party scripts impact page load times is becoming more important than ever. 

Don’t fear! There are a variety of steps you can take to improve your page load time and avoid getting marked down by Google. Below, I’ll provide 10 rules third-party script providers should follow to mitigate adverse effects caused by loading their scripts on customer web pages. But first, let’s start with a few basics you need to know in order to understand where to focus your energy.

Know Your Performance Ratings

Google has created a free tool known as PageSpeed Insights to help prepare site owners and builders for the upcoming change. To use PageSpeed Insights, simply input a URL to any given webpage. The tool will then analyze the site and calculate a page experience score, which I’ll cover in the next section. 

After using Google’s PageSpeed Insights tool on a few web pages, you’ll quickly realize that JavaScript is a common offender when it comes to slowdowns. Ad servers, trackers, and widgets all require JavaScript to display correctly on a webpage. These common plugins are sometimes full of bloat (e.g., unused dependencies), resource-heavy, and in need of optimization. 

Understand Page Experience Factors

Google’s new ranking signal is known as page experience, which indicates how “enjoyable” visiting a webpage may be for potential users. Google measures page experience using the following criteria: 

  • Mobile-friendliness: Including design, speed, navigation, and content flow.
  • Safe browsing: Telling visitors and web developers if pages might be compromised.
  • HTTPS implementation: Signaling whether or not a site makes a secure connection.
  • Interstitial ad presence: Determining if a site includes adverts that block content or force user interaction.
  • Core Web Vitals: NEW SIGNAL! Measuring both the speed and shifting of components on your website pages as they load into browsers.

Look Beyond SLAs

Setting up service level agreements (SLA) that continuously measure speed and availability is paramount to hitting healthy page speed rankings. SLAs also help hold vendors accountable for their commitments. At the same time, SLAs alone may be insufficient for mitigating all risks. 

External vendors can impact publishers in numerous ways, beyond page speed rankings. For example, vendor code execution can conflict with developer code, degrading the user experience for users of specific browsers or browser versions. Third-party resources can also deliver inappropriate content or harmful malware. 

To help prevent such adverse impacts, we’ve put together our top 10 rules for creating and managing third-party scripts. 

10 Rules For Creating Third-Party Scripts

1. Define and Enforce Meaningful SLAs

As a B2B service provider, you must establish clear SLAs. Ensure the SLAs are monitored and enforced so everyone across your organization understands the consequences of failure.

2. Use “ASYNC tags” to Avoid Blocking Content

The simple JavaScript code you’re using might be friendly to implement, yet it’s likely blocking page rendering during a system outage. Load your scripts asynchronously to minimize interference with other requests — including key events like DomContentLoaded and onload. Script placement before the closing body tag remains insufficient without ASYNC. Otherwise, load times will climb, pages won’t render, and bounce rates may increase significantly. 

3. Leverage Global Infrastructure for Content Delivery

Your clients place your tags on their pages and host visitors from various geographical regions. Accordingly, make your services reachable by catering to these locations. For example, U.S. West Coast servers aren’t ideal when your user base is primarily European. Strategically build your infrastructure by leaning on CDNs for static libraries and distributed DNS systems.

4. Write Safe Client-Side Code

If your JavaScript is executed on the window document (instead of your dedicated iframe), ensure that your variables, methods, objects, and events don’t conflict with existing elements. You shouldn’t be overriding, hiding, or blocking any content or pre-existing behavior. This could hurt the user experience unless it’s integral to the service (such as overlaying ads).

5. Upload Content Security 

Ensure that your system or service doesn’t deliver malware, phishing, or viruses. You should also confirm that the content is website-appropriate. For example, you wouldn’t serve alcohol-related ads on kids’ websites.

6. Don’t Hide in the Shadows

Link your tag domain to an index page with your company’s information, contact details, and privacy policy. Don’t anonymize domain Whois information. There’s nothing worse than a savvy end-user noticing a domain-holding page load, without knowing who owns said domain.

7. Respect Both Client and End-User Privacy 

Craft a clear, agreeable privacy policy that remains available to end-users. Don’t log any information that contradicts those binding policies. 

8. Support all Modern Browsers and Devices 

Treat all browsers and versions with respect, being careful not to make breaking, error-inducing changes (although some JavaScript-based functionality may be lost). Keep abreast of new technology and push updates as needed. 

9. Don’t Hog Resources 

Ensure your content doesn’t greedily consume bandwidth, CPU power, memory, or other resources. Remember that you’re not the sole page tag being used. Slowness does not serve the user and can be distracting from their primary content of interest. Minimalism and smart frugal resource utilization are crucial.

10. Create a Test Plan for New Releases

Test fresh tags and code on actual client web pages to ensure they’re not problematic. Experiment with different browsers and devices to confirm functionality. Notify clients of major changes, and remember to involve them in the testing process. Transparency is important. You might otherwise break something for your clients’ end users without them knowing.


Whether you’re a vendor or a website owner, I hope you’ve found these guidelines helpful for creating great user experiences. You can learn more by visiting Google’s portal hosting educational content on this topic or reading this free guide containing free educational content related to this topic. 

#Rules #Integrate #ThirdParty #Scripts