Wikipedia search using the JSON API
I would use map to replace all the data.query.pages[key]. into a single variable. Also ES6 template string is very useful, if you are not using ES6, just change it into one line string like you did in your original solution. map return an array, so I have to join('') them into a single string. Then I can just use it to pass to the jquery html() function and replace the content. Also, ? : shorthand for if else statement can produce less code in one line.

$('.sec-result .row').html(
    data.query.pages.map(page =&gt; (
        `&lt;div class="col-md-4"&gt;
            &lt;div class="box-result"&gt;
                &lt;div class="bg-result"&gt;&lt;/div&gt;
                &lt;a href="https://en.wikipedia.org/?curid=${page.pageid}" target="_blank"&gt;
                    &lt;div class="box-content center-block"&gt;
                        &lt;div class="article-thumbnail"&gt;
                            &lt;img src="${page.thumbnail ? page.thumbnail.source : 'http://www.wallpaperup.com/uploads/wallpapers/2014/04/02/319530/big_thumb_e96d0c33f97706bc093572bc613cb23d.jpg'}" alt="" /&gt;
                        &lt;/div&gt;
                        &lt;h1&gt;${page.title}&lt;/h1&gt;
                        &lt;p&gt;${page.extract}&lt;/p&gt;
                    &lt;/div&gt;
                &lt;/a&gt;
            &lt;/div&gt;
        &lt;/div&gt;`
    )).join('')
);


My solution is just for readability, it may not increase the speed though.