// Alternative to load event
document.onreadystatechange = function () {
    if (document.readyState === 'complete') {
        initBackToTop();
    }
}

initBackToTop = function() {

    var bttBtn = $('#back-to-top-button');

    $(window).scroll(function() {
            if ($(window).scrollTop() > 200) {
                bttBtn.addClass('show');
            } else {
                bttBtn.removeClass('show');
            }
        });

    bttBtn.on('click', function(e) {
            e.preventDefault();
            $('html, body').animate({scrollTop:0}, '300');
        });
};