News for hackers. Stuff that matters.
Re:Managing Async Dependencies with JavaScript by emergie on Saturday May 20, 2017 @02:36PM (#14383660)
lib you linked is a bit crazy, it uses setInterval to guess when a css is properly loaded/applied and delays running dependent code

imho this is sufficient:

    define('css', function () {
            return {
                    load: function (name, parentRequire, onload, config) {
                            console.log('loading css ' + name);
                            const link = document.createElement('link');
                            link.type = 'text/css';
                            link.rel = 'stylesheet';
                            link.href = name + '.css';
                            document.getElementsByTagName('head')[0].appendChild(link);
                            setTimeout(onload, 0);
                    }
            };
    });

usage:

    require(['lib/js/jquery-ui.min', 'css!lib/css/jquery-ui.min'], function () {
        // jquery-ui magic goes here
    });
Re:Managing Async Dependencies with JavaScript by hdhzy on Saturday May 20, 2017 @03:00PM (#14383775)
You don't need to guess, you can check document.styleSheets if it contains your file. See: https://curiosity-driven.org/minimal-loader#plugins