Due to a certain condition I have, I am unable to load some CSS and JS in my HTML. As a solution, I've decided to dynamically pull them using $.get()
. While I have successfully tested pulling and executing js
remotely, I am facing some challenges when it comes to css
.
Below is an example of pulling and executing js
from a remote CDN:
Pulling and Executing https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.1/jquery.min.js'>
Is it possible to fetch other javascript files remotely?
<pre>
<code class='java'>
System.out.println("It's done!");
</code>
</pre>
<script>
const highlightCDN = 'http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.2.0/highlight.min.js';
$(function(){
$.get(highlightCDN, function(data){
console.log('done!');
eval(data);
}).done(function(){
$('pre code').each(function(i, block){
console.log(i);
hljs.highlightBlock(block);
});
});
});
</script>
However, using eval
on css
is not an option. I am unsure of what to do next. Is there a workaround for this issue? Your help would be greatly appreciated!
P.S. If I pull js
as shown in my example, can I utilize it globally after its initial pull?