Skip to content

Instantly share code, notes, and snippets.

@samuelastech
Created April 28, 2022 13:38
Show Gist options
  • Save samuelastech/c5706e68f9817d4ed3f50c4fbfff3c4e to your computer and use it in GitHub Desktop.
Save samuelastech/c5706e68f9817d4ed3f50c4fbfff3c4e to your computer and use it in GitHub Desktop.
Using jQuery 'load' function we can break our HTML files into smaller parts
<script src="./js/jquery-3.6.0.js"></script>
<script>
$(function () {
const includes = $('[data-include]')
$.each(includes, function(){
let file = 'includes/' + $(this).data('include') + '.html'
$(this).load(file)
})
})
</script>
<div data-include="main"></div>
<div data-include="footer"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment