JS Simple Masking Image Load

I was messing with different ways of implementing forms of load masking and came across the site imagesLoaded So decided to have a little play about. First I programmatically add the JS’ needed to get this to work. function theme_preprocess_page(&$vars) { // Implement Simple image load masking drupal_add_js("https://unpkg.com/imagesloaded@4/imagesloaded.pkgd.min.js", array('scope' => 'header', 'type' => 'external', 'weight' => -1)); drupal_add_js(drupal_get_path('module', 'theme') . '/js/image-lazy-load.js', array('scope' => 'footer', 'weight' => 1, 'preprocess' => FALSE)); } I added a few additional options when adding the JS via drupal_add_js. »

Javascript Title Case Function

I’ve been tinkering with VueJS lately and one function that I’ve been using a lot recently is this toTitleCase function. Bring in dynamic content from an API results sometimes in text that I want to be a heading coming through as lowercase. So this little function with change it to title case for me. function toTitleCase(str) { return str.replace(/\w\S*/g, function(txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); }); } toTitleCase("web design"); Result: Web Design Theres also a little fiddle for this here. »