3 ms·
You can create a function to dinamycally add script tags to load other pieces of code, but you would end up implementing a whole module system.
by frozenlettuce 7y ago
You can create a function to dinamycally add script tags to load other pieces of code, but you would end up implementing a whole module system.
- EGreg 7y agoA long time ago we just implemented two methods: Q.exports(a, b, c) Q.require(src, callback) Following node but just async. It’s simple and it works. We were able to know the name of the latest loaded js file in exports() by a trick of throwing an exception and catching it to see what script was on the top of the stack. All browsers seem to support this. Since it worked back then, we didn’t need anything else. It is super simple to just keep using those things and replace the middleware underneath to whatever is the standard du jour. It's super short and simple, you can implement similar things in your projects: https://github.com/Qbix/Platform/blob/master/platform/plugins/Q/web/js/Q.js#L7842 https://github.com/Qbix/Platform/blob/master/platform/plugin... https://github.com/Qbix/Platform/blob/master/platform/plugins/Q/web/js/Q.js#L7826 https://github.com/Qbix/Platform/blob/master/platform/plugin...