<commit_before><script src="{{ "assets/jquery-3.2.1.min.js"| relative_url }}"></script>
<script src="{{ "assets/fuse.min.js"| relative_url }}"></script>
<script>

    function displayColors(colors) {
        $('.colors').html('');
        for (var k in colors) {
            var color = colors[k];
            var card = '<div class="col-xs-12 col-sm-6 col-md-6 col-lg-3"><div class="card mb-4"><div class="color" style="background-color: ' + color.hexadecimal + ';">&nbsp;</div><div class="card-body"><p class="card-text text-center"><strong>' + color.name + '</strong></p><table class="table table-sm"><tbody><tr><td>Hex</td><td class="text-right"><pre class="pt-1 mb-0"><code>' + color.hexadecimal + '</code></pre></td></tr><tr><td>RGB</td><td class="text-right"><pre class="pt-1 mb-0"><code>' + color.red + ',' + color.blue + ',' + color.green + '<code></pre></td></tr></tbody></table></div></div></div>';
            $('.colors').append(card);
        }
    }

    function getColors() {
        var search = $('#search').val();
        $.getJSON('{{ "assets/colors.json"| relative_url }}', function(colors) {
            if (search.length == 0) {
                displayColors(colors);
            }
            if (search.length >= 3) {
                var options = {
                    keys: ['name'],
                };
                var fuse = new Fuse(colors, options);
                colors = fuse.search(search);
                displayColors(colors);
            }
        });
    }

    $(document).ready(function() {

        $('#search').on('keyup', function(e) {
            getColors();
        });

        $('#reset').on('click', function(e) {
            e.preventDefault();
            $('#search').val('');
            getColors();
        });
<commit_msg>get json file on load only<commit_after><script src="{{ "assets/jquery-3.2.1.min.js"| relative_url }}"></script>
<script src="{{ "assets/fuse.min.js"| relative_url }}"></script>
<script>
    function displayColors(colors) {
        $('.colors').html('');
        for (var k in colors) {
            var color = colors[k];
            var card = '<div class="col-xs-12 col-sm-6 col-md-6 col-lg-3"><div class="card mb-4"><div class="color" style="background-color: ' + color.hexadecimal + ';">&nbsp;</div><div class="card-body"><p class="card-text text-center"><strong>' + color.name + '</strong></p><table class="table table-sm"><tbody><tr><td>Hex</td><td class="text-right"><pre class="pt-1 mb-0"><code>' + color.hexadecimal + '</code></pre></td></tr><tr><td>RGB</td><td class="text-right"><pre class="pt-1 mb-0"><code>' + color.red + ',' + color.blue + ',' + color.green + '<code></pre></td></tr></tbody></table></div></div></div>';
            $('.colors').append(card);
        }
    }

    function getColors(colorsList) {
        var search = $('#search').val();
            if (search.length == 0) {
                displayColors(colorsList);
            }
            if (search.length >= 3) {
                var options = {
                    keys: ['name'],
                };
                var fuse = new Fuse(colorsList, options);
                colors = fuse.search(search);
                displayColors(colors);
            }
    }

    $(document).ready(function() {

        var colorsList;
        $.getJSON('{{ "assets/colors.json"| relative_url }}', function(colors) {
                colorsList = colors;
            });

        $('#search').on('keyup', function(e) {
            getColors(colorsList);
        });

        $('#reset').on('click', function(e) {
            e.preventDefault();
            $('#search').val('');
            getColors(colorsList);
        });

{'fraction_non_alphanumeric': 0.21785132935431362, 'fraction_numerical': 0.008138903960933261, 'mean_word_length': 2.192207792207792, 'pattern_counts': {'":': 0, '<': 85, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3587356', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1095, 'n_words': 193}