Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

performance #10

Closed
wants to merge 2 commits into from

2 participants

@darrhiggs

changed loops and removed browser from ua()

darren added some commits
darren Removed browser as it was not needed when ua is called the first time. 51b5ebe
darren removeFaviconTag => Now using head rather than document to find links…
…. Changed loop to while to reduce variable count by 1. http://jsperf.com/tinycon-js-removefavicontag


getFaviconTag => Changed loop to while to reduce variable count by 1.
2ca916f
@tommoor
Owner

Thanks, this may be suspect to the same issue raised in #9 ?

@darrhiggs darrhiggs closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 8, 2012
  1. removeFaviconTag => Now using head rather than document to find links…

    darren authored
    …. Changed loop to while to reduce variable count by 1. http://jsperf.com/tinycon-js-removefavicontag
    
    
    getFaviconTag => Changed loop to while to reduce variable count by 1.
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 6 deletions.
  1. +8 −6 tinycon.js
View
14 tinycon.js
@@ -24,7 +24,7 @@
fallback: true
};
- var ua = (function (browser) {
+ var ua = (function () {
var agent = navigator.userAgent.toLowerCase();
// New function has access to 'agent' via closure
return function (browser) {
@@ -42,9 +42,10 @@
// private
var getFaviconTag = function(){
- var links = document.getElementsByTagName('link');
+ var links = document.getElementsByTagName('link'),
+ i = links.length;
- for(var i=0, len=links.length; i < len; i++) {
+ while (i--) {
if (links[i].getAttribute('rel') === 'icon') {
return links[i];
}
@@ -55,10 +56,11 @@
var removeFaviconTag = function(){
- var links = document.getElementsByTagName('link');
- var head = document.getElementsByTagName('head')[0];
+ var head = document.getElementsByTagName('head')[0],
+ links = document.getElementsByTagName('link'),
+ i = links.length
- for(var i=0, len=links.length; i < len; i++) {
+ while (i--) {
if (links[i].getAttribute('rel') === 'icon') {
head.removeChild(links[i]);
}
Something went wrong with that request. Please try again.