I'm currently using requirejs for loading majority modules, but i need to load single script knockout.js with old-fashioned manner using:
<script src='/path/to/knockout.js' ></script>
I have a trouble with it, when page is rendered i see this markup:
<script async="async" type="text/javascript" src="knockout.min.js"></script>
But i don't want to load knockout using require.js.
How to disable loading using require.js for specified script?
I FOUND A SOLUTION:
After digging up a sources of knockout, i found interesting pice of code, which determine existance of require.js and automatically registers module in require, Here is a guilty chunk of code:
// Support three module loading scenarios
if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') {
// [1] CommonJS/Node.js
var target = module['exports'] || exports; // module.exports is for Node.js
factory(target);
} else if (typeof define === 'function' && define['amd']) {
// [2] AMD anonymous module
define(['exports'], factory);
} else {
// [3] No module loader (plain <script> tag) - put directly in global namespace
factory(window['ko'] = {});
}
You can change as you want (for example you can replace function with something else) to achieve executing last else branch of code, and as result ko will be registered in global window space.