Reputation: 6625
Working on a Single Page Architecture project, there are a lot of *.js
files lazy loaded to DOM.
The file getting included may not have the line "use strict";
but the solution should force "use strict";
for all js files included after loading the initial scripts (Application library files).
Upvotes: 0
Views: 507
Reputation: 1434
Maybe you can use ajax to get the scripts text and append the "use strict";
to the scripts and eval()
it or append it to body as <script>
tag. Example using jQuery:
$.get('foo.js', function(script) {
$('<script type="text/javascript">').html('"use strict";\r\n' + script).appendTo('body');
// OR
eval('"use strict";\r\n' + script);
});
Upvotes: 1