VGTech is a blog where the developers and devops of Norways most visited website share code and tricks of the trade… Read more



Hover state on touch devices

Frontend

With an increasing number of users on tablets and smartphones, the need to take touch friendliness into consideration is greater than ever. Even though both the browsers and hardware are approaching desktop speed, there are still some issues with implementing web sites and web apps for these devices. (more…)


Capture The Flag!

Misc

Skjermbilde 2013-03-27 kl. 12.29.14A short time ago we released Capture The Flag; a set of web developer themed puzzles. There are ten levels for you to play with during easter.

The toplist show the time of the ten fastest to solve the (at the time of writing) ten levels of the CTF. Maybe we’ll see your name on the top of the list?

Happy holidays!

 


Vektklubb Android-app available

Android

We recently released an Android application for Vektklubb.no – a product that helps you lose weight, stay in shape and become healthier.

The app is a simple WebView-based wrapper, but we hope this can help new and existing users discover the mobile version of the product.

You can download the application for free over on Google Play – although actually using the application requires you to have an active subscription to Vektklubb.
(more…)



Speed up websites using DNS prefetching

Frontend

We recently added a couple of lines of HTML to our mobile website that potentially speeds it up for users with recent browsers (Chrome and Firefox, at the time of writing). The technique might not work for all sites, but it applied very well to ours. I’ll explain how and why (more…)



Using Elastica to query elasticsearch

PHP

The last couple of months I have been playing around with elasticsearch, an open source, distributed, RESTful search engine built on top of Apache Lucene. To interact with elasticsearch in PHP I have been using a client called Elastica. This was all fun and games until I needed to do actual queries, which is what our users will be doing most of the time.

Elastica’s documentation does not (yet) say anything about how to search using the client, so I needed to dig through the code to see if I could find some solutions. Some different methods exist, and I’ll present some of them here using different types of queries.

(more…)


Lazy Loading Resources with Zend Framework Bootstrap

PHP

The Bootstrapping process in Zend Framework isn’t perfect. You’ll often end up bootstrapping a lot of resources that you don’t need to complete the request. Depending on the resources this can be really expensive and hurt your overall performance.

The worst kind are resources that open connections to external services like MySQL and Memcached. Both Memcache::connect() and MySQLi::__construct() will try to connect to the server immediately and this can, and usually will be, “slow”. Even worse, if the services are down they will end up blocking the execution. (more…)


Strip HTML from a string in Javascript

JS

Quick tip; never use innerHTML (or jQuery’s html()) unless you really want to insert HTML.
Quite often, what you actually want is to insert some text. If this is the case, use innerText (or jQuery’s text()).

Should you need to strip HTML from a string (say you are building a chunk of HTML and need to insert the content of an input-field into it), this is a simple way of doing it:

Show code
function stripHtml(str) {
    var temp = document.createElement('DIV');
    temp.innerHTML = str;
    return temp.textContent || temp.innerText;
}

Or, if you’re using jQuery:

Show code
function stripHtml(str) {
    return jQuery('<div />', { html: str }).text();
}