Senior SEO Consultant

Share
  • 0
  • 0

The Priority index rating (PRI) is used by developers to decide whether an asset should be deferred or inlined.

Coupled with a ticket prioritization system, the PRI offers SEOs an opportunity to better engage with developers when it comes to optimizing JavaScript on a client’s website, and in theory with better collaboration will yield better results.

It’s oftentimes difficult to find the perfect balance between loading time and performance when tuning code for loading speed, and this is were the PRI can be useful.

A minimum threshold for PRI needs to be set in order not to break too many resources at once. It can be either set globally or per request based on its type. In general, 0-0.5 is a good value to aim for.

Old browsers like IE7 and 8 are notorious for causing slow-downs. Newer browsers use more modern JIT techniques that can detect what parts of a script are being used to decide which sections should be loaded into memory.

Developers who use PRI question whether an asset should be deferred, inlined or load with high priority (included inline).

Inlining is best when developers need a feature that will only be used once on a page; deferring is best if the asset might only be needed rarely but will still load fast if called; high-priority assets should always be included inline.

The PRI metric is a method of measuring the relative priority of an asset. It’s not a single algorithm or fixed value. Rather, it’s a set of heuristics which can help developers decide whether an asset should be deferred or inlined.

The developer will typically split the script into several groups using JavaScript comments and perform tests with different levels of priority; usually high, medium and low. The highest rated group will be inlined while the other high/medium/low groups will be deferred to ensure fast loading times on devices that are slow to download assets.

The developer should use runtime profiling tools to check which parts are being executed at the end of each test. The code should be optimized to prevent unnecessary DOM access and reduce the number of elements to be drawn.

The developer will then see whether the inlined scripts adversely affect the user’s experience when used in conjunction with a slow network. This could manifest itself as poor scrolling performance or unacceptably high memory usage.

 

Share
  • 0
  • 0