3 ms·
I don't have an iOS device but the website looks very good. Appreciate the write-up as well, it's always interesting to read about these things. Just a minor i
by rudasn 13y ago
I don't have an iOS device but the website looks very good. Appreciate the write-up as well, it's always interesting to read about these things.
Just a minor issue on the code you have on [1]:
imagesToPreload.forEach(function(src) {
var img = new Image();
img.src = src;
img.onload = hasLoaded;
img.onerror = hasError;
})
The onload and onerror callbacks would be best to be assigned prior to setting the image's src attribute so as to make sure they are always called.
Also, on your Element.hasClass method have you considered a non-regex approach, like this.className.split(' ').indexOf(c)? That would most probably be faster. Same goes for removeClass where something like this.className.split(' ').reduce(...).join(' ') may do the trick.
[1] http://www.scrambledapp.com/articles/for-developers/ http://www.scrambledapp.com/articles/for-developers/
- duopixel 13y agoiOS Safari supports element.classList since iOS 5. You can do... element.classList.add('classname') element.classList.remove('classname') element.classList.contains('classname') element.classList.toggle('classname')