Raku / raku.org

Source code for https://raku.org/
https://raku.org/
Artistic License 2.0
70 stars 50 forks source link

remove jquery #204

Open coke opened 12 months ago

coke commented 12 months ago

We are doing very little with it, and bootstrap doesn't need it to function.

It's doing some apparently unneeded work on the footer's CSS (I don't see a difference in chrome when I disable it), and pulling in the latest blog entries, which we can do with straight JS.

coke commented 11 months ago

Voldenet on IRC posted this potential replacement:

async function renderFeed() {
    const fragment = document.createDocumentFragment();
    try {
        const feed = await fetch('recent-blog-posts.json').then(x => x.json());
        for (const item of feed) {
            const li = document.createElement('li');
            const a = document.createElement('a');
            li.appendChild(a);
            a.href = item.link;
            a.appendChild(document.createTextNode(item.title));
            fragment.appendChild(li);
        }
    } catch (e) {
        const li = document.createElement('li');
        li.innerHTML = '<i>Failed to fetch recent blogs</i>';
        fragment.appendChild(li);
    }
    return fragment;
}

async function attachPosts() {
    const el = document.getElementById("recent_blog_posts");
    if (!el) return;
    el.appendChild(await renderFeed());
}

attachPosts();