Expand Script Loading

Service model

Rename IRouteHandler to IModule

Breaking change 0.2.0

Allow ID-

<script id="timelyScript" src="//book.gettimely.com/widget/book-button-v1.5.js"></script>

Page.Head.loadScript

top, bottom

loadScript ( body, head )

async

type

etc

Style

Consider additional safeties

  static loadTimelyScript(): Promise<void> {

    // Check to see if it exists? install only if needed? 



    return new Promise((resolve, reject) => {
      const script = document.createElement('script');
//      script.src = "//book.gettimely.com/widget/book-button-v1.3.js";
      script.src = "//book.gettimely.com/widget/book-button-v1.5.js";  
      script.id = 'timelyScript';
      script.onload = () => resolve();
      script.onerror = () => reject(new Error(`Failed to load script: ${script.src}`));
      document.head.appendChild(script);
    });
  }

Last updated