It’s the Web, just Kwwika

The real-time web. Delivered. 
Filed under

CSS

 

How to dynamically load JavaScript and CSS files

One of the requirements of the Opta Sports real-time Cricket widget (blog post | Opta Sports live cricket scores page) was that including the widget should be as simple as possible. One way to keep things simple is to only need to include one script tag which dynamically includes all required JavaScript and CSS files. We'd outsourced some of the widget development to Matador Digital and we passed this requirement on to them. They came up with a nifty bit of JavaScript that met exactly these requirements.

This example is tied to loading the files we required for our widget, including the Kwwika JavaScript API, but it wouldn't be at all difficult to take this code and create a small generic JavaScript and CSS loading utility function. The require function is generic and could easily be used as a solution to load any JavaScript or CSS file.

There are of course other solutions available:
A quick search will also come up with a number of solutions.

If you find any other solutions please get in touch and we'll update this post.

Filed under  //   CSS   JavaScript   Utilities  
Posted by email 

Comments [0]