lundi 29 juin 2015

Debug interface for code wrapped in requireJs


I've got a javascript program apps.js which is loaded in my index.html file like this:

<script data-main='apps.js' src='js/require.js'></script> 

where apps.js is auto-generated code, but includes a requirejs module. I would like to configure a test.html which loads a test.js file after apps.js is loaded. The purpose is that test.js lets me quickly test specific components from apps.js, so I want to treat apps.js as a standalone library.

What are my options?

One option I've found is for test.html to only load test.js in a data-main line, and then test.js to use something like this at its top:

$.ajaxSetup({async:false});
$.getScript("apps.js");
$.ajaxSetup({async:true});

but I'm not sure that's the best approach. Any other ideas? Thanks!


Aucun commentaire:

Enregistrer un commentaire