JS/CSS file loader

Use jQuery/JavaScript to dynamically load JS and CSS files after pageload.

by Preston Badeer

JavaScript

// Load JS file
var tag = document.createElement('script');
tag.setAttribute('type', 'text/javascript');
tag.setAttribute('src', path);
$('head').append(tag);

// Load CSS file
var tag = document.createElement('link');
tag.setAttribute('rel', 'stylesheet');
tag.setAttribute('type', 'text/css');
tag.setAttribute('href', path);
$('head').append(tag);