Well, I'm trying to doing $('element').load()
call. Because, I want to load content only on desktops and tablets, not in mobile. So to avoid data redundancy I'm doing the following (after my $(document).ready(func...)
):
$('section[data-showif="only-sm"]').each(function(index) {
if($(window).width() > 992)
$(this).load("/html/" + $(this).data("htmlinclude") + ".html");
});
I have a section with the following data:
<section id="github-cards" data-showif="only-sm" data-htmlinclude="github-cards-content">
</section>
And then, in my html/github-cards-content.html
file I have this:
<div class="container gitcards">
<div class="row">
{% for repo in site.data.repos %}
<div class="col-md-4">
<div class="github-card" data-github="{{ repo }}" data-theme="default"></div>
</div>
{% endfor %}
</div>
</div>
This is not important, but I'm using Github Cards to display my projects.
And this is my yml file under: _data/repos.yml
:
- "uta-org/QuickFork"
- "uta-org/ZWSetup"
- "uta-org/uzLib.Lite"
This work perfectly if I only just put the contents from github-cards-content.html
into my section. But if I do what I explained, the Liquid code is shown (I want to avoid it).
I could imagine that I can't load liquid templates/content without calling {% include file... %}
, but I want to know if there is any workaround for this.
EDIT:
This what a guy said:
Liquid is rendered server-side so you will not be able to render liquid after the page loads using jquery. You can circumvent this issue by inserting whatever code resides in 'liquidcode.html' from the very beginning, but hiding it by adding a class to the div with display set to none. You can then remove that class when the user clicks on "Click".
https://stackoverflow.com/a/44398827/3286975
I could imagine something like that. But is there any plugin that makes server to render without sending data to the client until needed? (I need this because in mobile I need to avoid as less as possible data to be sended to the client, because of roaming)