Script Loader
How to use the Edgemesh Script Loader.
The Edgemesh Script Loader allows developers to specify when specific scripts should be loaded in the page's lifecycle. When set up properly, this can prevent page blocking and drastically improve a pages core vitals.
Using the script loader is as simple as changing the type of a script from application/javascript to one of the custom Edgemesh types outlined below. The script loader works with both inline and external javascript.
If you are an Edgemesh Server customer, you can use the attribute data-em-load instead of modifying the type directly. Since the Edgemesh Client is dynamically injected, this will ensure that your scripts still load on your backend site.

Before Interactive

Loads the given script before the page becomes interactive. This setting is appropriate for scripts that are required to render the page, but shouldn't block parsing of the DOM.
Edgemesh Client
<script type="edgemesh/beforeInteractive" src="https://foo.com/script.js"></script>
Edgemesh Server
<script
type="application/javascript"
src="https://foo.com/script.js"
data-em-load="beforeInteractive">
</script>

After Interactive

Loads the given script after the page has become interactive. This setting is useful for when you want a script to load after the page is able to be interacted with by the user. Use this setting for important scripts that are not required to load the page.
Edgemesh Client
<script type="edgemesh/afterInteractive" src="https://foo.com/script.js"></script>
Edgemesh Server
<script
type="application/javascript"
src="https://foo.com/script.js"
data-em-load="afterInteractive">
</script>

Lazy On Load

Loads the given script after the page is fully loaded. This setting is useful for heavy javascript that are not immediately required by the page. For instance, most third party analytics and apps can be lazy loaded.
Edgemesh Client
<script type="edgemesh/lazyOnLoad" src="https://foo.com/script.js"></script>
Edgemesh Server
<script
type="application/javascript"
src="https://foo.com/script.js"
data-em-load="lazyOnLoad">
</script>

Web Worker

The ability to off load a script to another thread via Web Workers is coming soon.
It's important that the Edgemesh Client script is loaded with application/javascript in order for the script loader to function.
Copy link
On this page
Before Interactive
After Interactive
Lazy On Load
Web Worker