Подключить InstantClick и заставить его отправлять статистику просмотров в google analytics при каждом изменении страницы.

<script
  data-no-instant
  src='//cdnjs.cloudflare.com/ajax/libs/instantclick/3.0.1/instantclick.min.js'>
</script>
<script data-no-instant>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;
  i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},
  i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;
  m.parentNode.insertBefore(a,m) })(window,document,'script',
  '//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-xxxxxxx-x', 'xxxxxxxxxxx.ru');

  InstantClick.on('change', function() {
    ga('send', 'pageview', location.pathname + location.search);
  })

  InstantClick.init();
</script>

Объявляем объект console, если его нет у браузера, для случая когда кто-то случайно оставит console.log в коде.

window.console = window.console || (function(){
    var c = {};
    c.log = c.warn = c.debug = c.info = c.error = c.time = c.dir =
      c.profile = c.clear = c.exception = c.trace = c.assert = function(s){};
    return c;
})();

Объявляем window.location.origin для ie

if(!window.location.origin) {
  window.location.origin =
    window.location.protocol +
    "//" + window.location.hostname +
    (window.location.port ? ':' + window.location.port: '');
}

Значение по умолчанию в javascript

this.timeout = p.timeout || 5000

Добавить к html элементу событие, так что оно будет выполняться в пространстве этого элемента

<a href='#' onclick='return js_link.call(this)'>link</a>

Итерация по объектам

for (var k in window.document)
    document.write(k + " - " + window.document[k] + "<br>")

var a = [function(sep){
    return 'a_b_c'.split(sep);
}];
a[0]('_')[0]; 

Перенаправить пользователя на другую страницу

window.location = 'http://ya.ru'

Перезагрузить страницу

window.location.reload()

Обходим только собственные свойства объекта

<script>
obj = {foo: 1, bar: 2, barobj: {75: true, 76: false, 85: true}}
for(var prop in obj) {
    if(obj.hasOwnProperty(prop)){
        document.write(prop + ': ' +obj[prop] + '<br>')
    }
}
</script>
foo: 1
bar: 2
barobj: [object Object]

Спрашиваем бразуер о местоположении

if(navigator.geolocation){
    navigator.geolocation.getCurrentPosition(function(fsbkgb) { 
      var pod_kolpakom = true; 
    });
} 

Открыть из javascript ссылку в новом окне

window.open('http://www.mydomain.com?ReportID=1');

Получить элемент по id

function byid(id){
  return document.getElementById(id);
}

Удалить элемент из массива

Array.prototype.remove = function(e) {
  var t, _ref;
  if ((t = this.indexOf(e)) > -1) {
    return ([].splice.apply(this, [t, t - t + 1].concat(_ref = [])), _ref);
  }
};
var arr = [1,2,3,4,3]
arr.remove(3)
console.log(arr)
[1,2,4,3]

Сериализовать объект в JSON и обратно.

JSON.stringify({foo: 'bar'})
'{"foo":"bar"}'
JSON.parse('{"foo":"bar"}')
{ foo: 'bar' }

Получить ширину и высоту элемента или изображения на экране

var img = document.getElementById('imageId');

var width = img.clientWidth;
var height = img.clientHeight;
-----------
-----------