In this example, we'll improve page load speeds by adding external CSS & JS assets.

# 1. Page with 3 mods on it

Let's say we have the 3 mods on our page, so that our page HTML contains the following:

<!-- Mod with Vue JS -->
<div id="anymod-lrmmr"></div>

<!-- Mod with Bootstrap CSS, reCAPTCHA JS, & Axios JS -->
<div id="anymod-obkka"></div>

<!-- Mod with Bulma CSS -->
<div id="anymod-bobmm"></div>


If 2 mods share the same asset, it will still only be loaded once. Similarly, if the page already contains an asset that mods use, it will only be loaded once.

Taken together, the 3 mods above have the following external assets added to them:

Name Type URL
Vue.js JS
Bootstrap CSS
Axios JS
Bulma CSS

By default, AnyMod will load all of the assets needed for these mods automatically, and the mods will work right out of the box.

However, in order to know which assets to load, AnyMod has to make a request when the page is first parsed, and then load the assets. This is fast, but we can make the process even faster by eliminating this first request.

# 2. Reading the browser console

When a page with the above 3 mods is loaded, the browser console will display a message with suggestions on how to improve performance.

Following the suggestion, we can paste the asset tags into the document's <head>:


  <title>Example web page</title>

  <!-- AnyMod assets -->
  <link href="" rel="stylesheet">
  <link href="" rel="stylesheet">
  <script defer src=""></script>
  <script defer src=""></script>
  <script defer src=""></script>
  <!-- /AnyMod assets -->

  <!-- AnyMod script -->
  <script id="AnyMod-script">
    (function (m,o,d,u,l,a,r,i,z,e) {
      u[m]={Project:o,rq:[],Opts:r,ready:function(j){u[m].rq.push(j)}};function j(s){return encodeURIComponent(btoa(s))};z=l.getElementById(m+'-'+a);r=u.location;
  <!-- /AnyMod script -->

# 3. Reload the page

Now when we load the page, the browser console no longer offers any suggestions since we have optimized the asset load sequence.

By adding the assets directly to the page, the browser can load the assets in parallel with the mods, making the page load faster.

Last Updated: 7/14/2019, 9:24:23 PM