If the web seems slow, blame third-party advertising and analytics scripts.

Many internet users have already come to that conclusion but Patrick Hulce, founder of Dallas, Texas-based Eris Ventures and a former Google engineer, has assembled data that clarifies the impact of third-party scripts in the hope it prompts more efficient coding.

Hulce has compiled a list of the third-party scripts residing in the top million websites and found that the 100 most common bits of JavaScript eat up about 59 per cent of script execution time.

"Third party script execution is the majority chunk of the web today, and it's important to make informed choices," he says in the GitHub post where he presents the data.

Hulce during his time at Google worked on Lighthouse, a developer tool for browser performance profiling. It's available in Chrome, from a command line app, or as Node.js modules.

Latency

Third party scripts represent only one factor that comes into play when calculating total web page load time. Network latency, bandwidth, file sizes and device processing power all come into play. But the time it takes to execute JavaScript code can have a significant impact too.

In an email to The Register Hulce explained that there are different types of user-perceived delay. "Visual delay, when nothing shows up or things are obviously still loading slowly, tends to still be dominated by network latency and large resource payloads," he said. "Large script files can contribute here, but execution time isn't always the biggest culprit."

At the same time, delays affecting interactivity, he said, like when users try to click on an icon and nothing happens immediately, are almost exclusively the results of JavaScript execution. "Bringing down JavaScript execution times has a very large impact on this type of delay," he said.

Hulce's data, gathered through the HTTP Archive project in conjunction with Lighthouse on mobile, reveals Google's scripts impose more delays than anyone else's. The two biggest offenders are Google/Doubleclick Ads, adding 330 ms on average, and Google Tag Manager, adding 386 ms on average.

Name and shame

These two scripts have the most impact because they're the most commonly found in website code, the former devouring a total of 466,442 seconds (~5.4 days) of execution time and the latter consuming 421,590 (~4.9 days) seconds during the twice monthly data gathering periods. Facebook code comes in fourth overall, accounting for 145,169 seconds (~1.7 days).

In terms of the worst average delay, the crown goes to WordAds, a WordPress ad system, which typically eats up 2543 ms every time it loads. 33 Across ad scripts (1170 ms) and Wix platform scripts (1153 ms) also take a long time to execute.

By making this information available, Hulce hopes to help encourage efficient coding. "If users express a preference for third parties with a lighter performance cost, it could have a huge impact across the ecosystem," he said. "I'd be happy to see third parties compete on performance too and not just their feature set."

Many web users who have already come to see third-party scripts as the source of their troubles have opted-out by installing content or ad blocking extensions in their browsers or by blocking third-party requests on a network level.

Hulce isn't a fan of this approach. "I don't think ad-blockers are a long-term solution to the web's script problem," he said. "Sites need revenue, and the threat of ad-blockers in some cases actually makes the situation worse for the rest of users by triggering convoluted workaround logic and complex disguising of ads that increase script execution time."

You like JavaScript! You really like it! Scripting lingo tops dev survey of programming languages READ MORE

There can be circumstances where ad-blocking scripts cause delays – one of the reasons Google has proposed changes to its Chrome Extensions API is to reduce these supposed delays – but users of content blocking software argue third-party scripts rather than software blocking them represent the greater source of slowdowns.

As one user of content blocker uBlock Origin said the software "makes popular web pages load several times faster and consume several times less memory by reducing the amount of ad iframes and such."

Browser maker Opera claims its built-in desktop ad blocking system speeds up web page loading by as much as 90%.

Hulce hopes internet users make the ecosystem better by recognizing good behavior. "I'm convinced that rewarding sites that deliver positive experiences is the path forward," he said. "Let publishers follow the money from there."

If that's to happen, advertisers and publishers will need to find self-restraint they've never exhibited and platform owners will need to get serious about policing marketing excess, misinformation and malice instead of just issuing apology after apology. ®