There is many options to include HTML inside another HTML code. I am not interested in the PHP option and looking for the best JavasSript solution. I found the following codes :
<div w3-include-html="content.html"></div>
<script>
w3.includeHTML();
</script>
and the jQuery option with "load" method :
$(document).ready(function() {
$('#item').load('example.html');
});
Which option is the best? i mean which option is supported accross the majority of browsers versions.
Thanks
These are effectively the same method, from the perspective of browser support. Both involve JavaScript to use XHR (aka AJAX) to get HTML from the server and inject it into the page.
In most cases, it's better to assemble your page server-side, for at least a few reasons: