Reputation: 1023
I have seen some questions but non of the answers apply to me.
I have two scripts
<script src="js/bootstrap.min.js"><script>
<script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script>
Depending on which order I place them the code for the other breaks. When I look at the source code I see its because the function names conflict. I need to load both.
Can I somehow make the entire second library load into a separate namespace? How do I go about making all the functions load from both scripts :/
What I'm trying to do
I need to call prettyPrint()
from run_prettify.js
what prettyPrint()
does is insert <ol>
's and <li>
's and <span>
's and into my tag which contains a chunk of code. Then once those tags are inserting my custom css can style the chunk of code.
Upvotes: 0
Views: 426
Reputation: 1746
Have a look at RequireJS http://requirejs.org/. It is a library designed to build javascript modules which are completely self contained and manages dependencies for you as well.
Using RequireJS you could do something like:
require(["js/bootstrap.min"], function(bootstrap) {
//use bootstrap here
});
require(["https://google-code-prettify.googlecode.com/svn/loader/run_prettify"], function(run_prettify) {
//use run_prettify here
});
Upvotes: 1