File: example/impl.js

Recommend this page to a friend!
  Classes of Elger van Boxtel   JS loader   example/impl.js   Download  
File: example/impl.js
Role: Example script
Content type: text/plain
Description: Example Javascript
Class: JS loader
Load JavaScript and CSS resources dynamically
Author: By
Last change: Update of example/impl.js
Date: 2 years ago
Size: 855 bytes
 

Contents

Class file image Download
document.addEventListener('DOMContentLoaded', function () { document.querySelector('.load').addEventListener('click', function(){ /** * Load JQuery from a CDN. Execute the callback when finished */ Loader.loadJs('https://code.jquery.com/jquery-2.1.1.js', function(){ console.log('JQuery JS loaded'); }); /** * Load JQuery css. Execute the callback when finished */ Loader.loadCss('https://codeorigin.jquery.com/jquery-wp-content/themes/jquery/css/base.css?v=1', function(){ console.log('JQuery CSS loaded'); }); }, false); document.querySelector('.unload').addEventListener('click', function(){ /** * Load JQuery css. Execute the callback when finished */ Loader.unloadCss(/.*codeorigin\.jquery\.com.*/, function(regex, stylesheet){ console.log('JQuery CSS removed ' + stylesheet); }); }); });