WP rest api loads very slow
-
Hi,
I registered custom route and return only the title, the permalink and the featured image. I used jQuery $getJSON(); to pull in random recipes for a food blog. But it seems to load very laggy and slowly.
I don’t know what is the reason. Please advice me!
Here is the code:$(“#getIdeasButton”).on(“click”, function() {
clearTimeout();
$(“#cookieLoader”).css(“visibility”,”visible”);
$(“#cookieLoaderText”).css(“visibility”,”visible”);
$(“#cookiesDiv”).css(“visibility”, “hidden”);
$(“#cookieIdeaButton”).css(“display”,”none”);
setTimeout(function() {
$(“#cookieLoader”).css(“visibility”,”hidden”);
$(“#cookieLoaderText”).css(“visibility”,”hidden”);$.getJSON(localBlogData.root_url + ‘/wp-json/gbf/v1/randomrecipes’, function(results) {
$(“#cookiesDiv”).html(`<div>${results.map(item =>
<p class="courseText">Breakfast</p><h1 class="recipeLink"><a href="${item.permalink}">${item.title}</a></h1>)}
<div class=”phpImage”>${results.map(item =><a href="${item.permalink}"><img id="cookieImage" src="${item.featured_image}" /></a>)}</div></div>
`);$(“#cookiesDiv”).css(“visibility”, “visible”);
$(“#cookieIdeaButton”).css({“display”:”block”, “margin”:”0 auto”,”margin-top”:”10px”});
console.log(‘click’);
});
}, 500);I used the same code for the individual buttons as well.
Is it the wp jquery combination? Should I use a different method?Thanks in advance!
The page I need help with: [log in to see the link]
The topic ‘WP rest api loads very slow’ is closed to new replies.